General discussion

Locked

How do i track the browser back button.

By kpsamkumar ·
I want to track the browser back button when i click the back button of the browser, using javascript.

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

How do i track the browser back button.

by Jay Eckles In reply to How do i track the browse ...

Using the onLoad or onUnload events (depending on what you're trying to do), investigate the history object.

Collapse -

How do i track the browser back button.

by kpsamkumar In reply to How do i track the browse ...

The question was auto-closed by TechRepublic

Collapse -

How do i track the browser back button.

by rstapde In reply to How do i track the browse ...

The following html code works in IE.

Hope this helps.

<html>
<head>
<title>Capture Key and Mouse Keys</title>
<script language="javascript">
var gKey = '';
var cInp = 'yrros';


function checkWhich(evt) {
var theKey;

if (window.event.srcElement.type == "textarea") { status = window.event.keyCode }
if (window.event.srcElement.type == "button") { theKey = window.event.button; }
else { theKey = window.event.button }

alert('The key = ' + theKey + ' global key = ' + gKey);
return false;
}

function docKeyHandler() {
if ( window.event.srcElement.type == "text"
|| window.event.srcElement.type == "textarea"
) { return true;}

if (event.keyCode == {
alert('Come on Dont press backspace on me !!!!! ' + window.event.srcElement.type);
return false;
}
}

function docMouseKeyHandler() {
if (event.button == 2){
alert('This key is disabled');
return false;
}
}
document.onkeydown = docKeyHandler;
document.onmousedown = docMouseKeyHandler;

</script>

</head>


<body style="FONT-FAMILY: Arial" name="bodymain" background="cyan">

<form name=formmain method=post>
<INPUT NAME="Field 1 "> <INPUT NAME="Field 2 ">

<P>Press Back Space or Right Click with your mouse outside the fields</P>
</form>
</body>
</html>

Collapse -

How do i track the browser back button.

by kpsamkumar In reply to How do i track the browse ...

The question was auto-closed by TechRepublic

Collapse -

How do i track the browser back button.

by kpsamkumar In reply to How do i track the browse ...

This question was auto closed due to inactivity

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums