How to disable back button of browser and not delete the history?

To disable back button of browser … delete history
Put this javascript at the <head> tag
    <script type=”text/javascript”>
        function setFocus()
        {
            document.getElementById(“contentPage”).focus();
            var URL;
            var i;
            var QryStrValue;
            URL = window.location.href;
            i = URL.indexOf(“?”);
            QryStrValue = URL.substring(i + 1);
            if (QryStrValue != ‘X’)
            {
                window.location = URL + “?X”;
            }
        }
     </Script>

Then call your function using onload event in <body> tag.
<body onload=”setFocus()”>

Here is the reference that I use:
http://www.daniweb.com/web-development/javascript-dhtml-ajax/threads/60682

Advertisements
This entry was posted in ASP.NET 3.5 And JavaScript, HTML And JavaScript, JavaScript. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s