Tuesday, November 15, 2011

Disabling the Back button in browser

Found at:
http://viralpatel.net/blogs/2009/11/disable-back-button-browser-javascript.html

Seems to work in IE need to try in others
BUT just in case:

Following is the code to open webpage in a new window have no toolbar (Back/Next buttons).
1
2
window.open ("http://viralpatel.net/blogs/",
"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
2
3
4
5
6
7
<SCRIPT type="text/javascript">
    window.history.forward();
    function noBack() { window.history.forward(); }
</SCRIPT>
</HEAD>
<BODY onload="noBack();"
    onpageshow="if (event.persisted) noBack();" onunload="">

Tuesday, November 8, 2011

Deprecated iframe in HTML5

Found this useful site: http://www.dreamincode.net/forums/topic/195687-iframe-replacement/
uses the object tag instead of iframe.
There is no REAL replacement - DIVs may be a way to section off a bit of a page
but still NOT a replacement

In essence:

Adding Functionality
Go back to your "index.html" file, and change your object element to look like this:

We have just added some functionality to the object element. Save it and open it up in your browser. "framed.html" will show up in a small part of the page!

Finishing
However, we aren't finished just yet! We still have to add the backup in case a URL that doesn't work is placed into the object element. We will call this code the "Fallback code" that the browser goes to when a link doesn't work.
Add this to your object element:
<object data="framed.html" type="text/html"><p>This is the fallback code!</p></object>