Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.
$(function() {
$(window).scroll(function() {
if($(this).scrollTop() !== 0) {
$('#toTop').fadeIn();
} else {
$('#toTop').fadeOut();
}
});
$('#toTop').click(function() {
$('body,html').animate({scrollTop:0},800);
});
});
<<!DOCTYPE html>
<html>
<head>
<title>BootBox</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script type="text/javascript" src="/home/allan/Workspace/Dev/www/Test/bootbox/bootbox.js"></script>
</head>
<body>
<a class="butt" href="http://www.google.com">click mes</a>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('.butt').click(function(e) {
e.preventDefault()
var targetUrl = $(this).attr("href");
bootbox.confirm("Message", function(result){
if (result == false)
console.log("Prompt dismissed");
else
window.location = targetUrl
});
});
});
</script>
</body>
</html>