Sell And Buy

Monday 9 November 2015

Open A New Window without Back Button using javascript

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


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

Disable the right click on any webpage using Javascript

<body oncontextmenu="return false;">  

Disable Back functionality using history.forward

 

<SCRIPT type="text/javascript">
    window.history.forward();
    function noBack() { window.history.forward(); }
</SCRIPT>
</HEAD>
<BODY onload="noBack();"
    onpageshow="if (event.persisted) noBack();" onunload="">

Warn User if Back is Pressed

 

Following Javascript snippet will add a warning message in case Back button is pressed:
window.onbeforeunload = function() { return "You work will be lost."; };

 ONLINE DEMO