Skip to content

Instantly share code, notes, and snippets.

@xhimalaya
Created June 26, 2022 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xhimalaya/9451a4bee637de9bc9660331ca4b84ac to your computer and use it in GitHub Desktop.
Save xhimalaya/9451a4bee637de9bc9660331ca4b84ac to your computer and use it in GitHub Desktop.
Toastr Example
<p>Click <a href="http://codeseven.github.io/toastr/demo.html" target="_blank">here</a> for more examples.</p>
<br/>
<p>You'll notice that the JS is more or less empty and is just what I need to make the example work.</p>
<p>I linked my CodePen to use the following two files:</p>
<ul>
<li><a href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css" target="_blank">toastr.min.css</a></li>
<li><a href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js" target="_blank">toastr.min.js</a></li>
</ul>
// Set the options that I want
toastr.options = {
"closeButton": true,
"newestOnTop": false,
"progressBar": true,
"positionClass": "toast-bottom-center",
"preventDuplicates": false,
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
}
$(document).ready(function onDocumentReady() {
setInterval(function doThisEveryTwoSeconds() {
toastr.success("Hello World!");
}, 2000); // 2000 is 2 seconds
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment