0% found this document useful (0 votes)
57 views

Js Tricks

1. The document provides code to open a webpage in a new window without toolbar buttons using JavaScript. 2. It also shares code to disable right click functionality on a webpage by returning false on contextmenu. 3. The final part demonstrates how to disable the back button functionality by using history.forward to prevent a user from navigating back to the previous page.

Uploaded by

phd_151289
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

Js Tricks

1. The document provides code to open a webpage in a new window without toolbar buttons using JavaScript. 2. It also shares code to disable right click functionality on a webpage by returning false on contextmenu. 3. The final part demonstrates how to disable the back button functionality by using history.forward to prevent a user from navigating back to the previous page.

Uploaded by

phd_151289
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Following is the code to open webpage in a new window have no toolbar (Back/Next

buttons).

?
1window.open ("http://viralpatel.net/blogs/",
2"mywindow","status=1,toolbar=0");

Also it is possible to disable the right click on any webpage using Javascript. Add
following code in the webpage.

?
1<body oncontextmenu="return false;">

Disable Back functionality using history.forward


This is another technique to disable the back functionality in any webpage. We can
disable the back navigation by adding following code in the webpage. Now the catch
here is that you have to add this code in all the pages where you want to avoid user to
get back from previous page. For example user follows the navigation page1 ->
page2. And you want to stop user from page2 to go back to page1. In this case all
following code in page1.

?
1<SCRIPT type="text/javascript">
2 window.history.forward();
3 function noBack() { window.history.forward(); }
4</SCRIPT>
5</HEAD>
<BODY onload="noBack();"
6 onpageshow="if (event.persisted) noBack();" onunload="">
7

The above code will trigger history.forward event for page1. Thus if user presses
Back button on page2, he will be sent to page1. But the history.forward code on page1
pushes the user back to page2. Thus user will not be able to go back from page1.

You might also like