JavaScript Tutorials
- What is Javascript?
- What is BOM?
- What is DOM?
- Variable
- check variable value is empty
- JavaScript Output
- Functions
- Javascript Events
- Input Events
- onchange Event
- Javascript Output methods
- If else statement
- Arrays
- Pattern Validation
- Form Validation
- Inner Html Form Validation
- Inline Form Validation
- Checkbox Validation
- Inline Inner Html Form Validation
- Server side php Validation
- Validate a HTML Form with PHP
- window and window location
- Get Text Value
- Get hidden field value
- JavaScript & PHP
- Date Format
- get php value in javascript
- Redirect page & Autoredirect page
- Auto Refresh page & Div
- How to get select text value from Dropdown box
- How to clear browser history in javascript
- Checkbox Problems
- Select option problems
- Popup Contact Form
- Sidebar Contact Form
- How to use a multistep Form or Form wizard
- Auto Calculate Price
- print Application Form
- Auto Calculate GST in Javascript by select price
- Calculate GST by input value in text box Jquery
- Calculate Discount
- onClick Checkbox
- autofil form data click on checkbox
- Show subcategory list
- Show city list as per state
- Show district list as per country and state
- Show good morning good night wish
- image upload with preview image
- Print Div Content
- Show modal popup on page load
- filter table data usign javascript.
- Character Limit Validation.
- Validate File 5MB Upload
- Validate Special character
- More File Upload
- Call JavaScript Function After Page Load
- Drop Down First option Value Disabled --- Please Select ---
- How to Disable Submit Button After Form Submission
- How to disable browser back button using Jquery?
- How to Remove selected item from second & third dropdown list?
- Interview Questions of JavaScript.
Important Link
How to clear browser history .
Clear Browser History using Javascript
If you need to clear the Browser History, after arriving on a particular page (e.g. arriving to Login page after Logout), below is the wicked way. This script needs to put in only on one page, from where you do not want to move back.
<script type="text/javascript">
window.onload = function () { Clear(); }
function Clear() {
var Backlen=history.length;
if (Backlen > 0) history.go(-Backlen);
}
</script>
Second, if you do not want the user to move to the back page, you can do as below. This script needs to be repeated at every page.
if(window.history.forward(1) != null)
window.history.forward(1);
</script>
<script type = "text/javascript" >
function disableBackButton()
{
window.history.forward();
}
setTimeout("disableBackButton()",0);
</script>
<body onunload="disableBackButton()" onload="disableBackButton()">
</body>
Clearing browser history from javascript after logout
Clearing browser history was eating my head. After the user clicks the logout from the portal and clicks on the back button from the browser, it get back the previous page. Finally I did it by the below steps, which I found to be interesting.
Step 1. Add the below javascript code on the page load
<script>
function callme()
{
history.go(1);
}
</script>
Step 2. Dont allow the page to be saved in cache. Add the below lines between <head>
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
Step 3. On click of Logout. Clear the history from the browser and redirects to Login page from server side.
string strScript = "<script>var Backlen=history.length;history.go(- Backlen);window.location.replace('Login.aspx');</script>";
ClientScript.RegisterClientScriptBlock(this.GetType(), "ClearHistory", strScript);
<script type="text/javascript">
function noBack()
{
window.history.forward()
}
noBack();
window.onload = noBack;
window.onpageshow = function(evt) { if (evt.persisted) noBack() }
window.onunload = function() { void (0) }
</script>