My network security professor want's us to create a web page that a user can't navigate away from using the URL bar, or bookmarks.
His hints were to use onbeforeunload
and onunload
.
Target browser is Firefox.
My network security professor want's us to create a web page that a user can't navigate away from using the URL bar, or bookmarks.
His hints were to use onbeforeunload
and onunload
.
Target browser is Firefox.
<html>
<head>
<script type="text/javascript">
window.onbeforeunload = function() {
setTimeout(function() {document.location.reload()}, 0);
}
</script>
</head>
<body>
<a href="http://www.google.com">I won't work</a>
</body>
</html>
If you try to navigate to another site using the address bar, bookmarks, or links, you will be brought back to this page.
<html>
<head>
<title>Jquery stop</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
function unloadPage(){
return "dont leave me this way";
}
window.onbeforeunload = unloadPage;
</script>
</head>
<body>
<a href="www.example.com/">I am leaving</a>
</body>
</html>
You could use JQUery to do all the work
so here is a example here, but for a full example
<html>
<head>
<script type="text/javascript">
window.onbeforeunload = function() {
return "Are you sure you want to navigate away?";
}
</script>
</head>
<body>
<a href="http://www.example.com">Link</a>
</body>
</html>
Remember we are here to help and answer the question not to do you assignment