A tiny inline javaScript library for displaying custom alerts or pop-ups.
The file size is 2kb, nothing to worry about!
Helps you write fashionable alerts directly with HTML without needing to write your JavaScript inside a script tag.
The source link should be placed inside the head section of your html document.
To start using, you either link from the CDN
<script src="https://rawcdn.githack.com/stonny71/pling/95d346c1c9ad0faa10c73ee3c041ea8e1fb8a4e8/pling.js"> "> </script>
OR download the source and host from your computer.
<script src="pling.js"> </script>
<!DOCTYPE html>
<html>
<<head>
<title>Pling js </title>
<script src="https://rawcdn.githack.com/stonny71/pling/95d346c1c9ad0faa10c73ee3c041ea8e1fb8a4e8/pling.js"></script>
</head>
<body>
<button onclick="Pling('Hello world')">demo</h1>
</body>
</html>
The first argument is the content of the alert while the second argument is the title.
<button onclick="Pling('I am the content', 'I am the title')"> demo </button>
To display alert without a title, the second argument should not be included.
<button onclick="Pling('I am the content')"> demo </button>
Pling.js works like JavaScript alert() function, just that Pling.js provides extra parameters for adding more features to your alerts.
All you just need is replace alert with Pling
<script>
Pling('I am the content');
</script>
In the below sample, Pling.js is used to display the current year.
<script>
function showYear(){
d= new Date();
year = d.getFullYear();
Pling(year, "The current year is");
}
</script>
To add a custom css to the alert, include the third argument.
The third argument is a name you will use inside your css sheet;
sample:
Pling("hello my button is red", "red button", "custom");
<button onclick = 'Pling( "content", "title", "custom")'>
</button>
<style>
/**main container**/
.custom .box{
background:#333 !important;
color:#fff !important;
}
/**title of the alert**/
.custom .title{
background:#64B5F6 ! important;
color:#fff !important;
}
/**content of the alert**/
.custom .content{
color:#fff !important;
}
/**ok button**/
.custom .btn{
background:#333 !important;
color:#fff !important;
}
</style>
Always add !important while trying to add custom colors in the css sheet. e.g
Pling("Have a nice day my friend <br/> I wish you good luck");