I having trouble with this code, I have this timer running in a js file if the timer runs out then an alert box pops up letting the user know that they have been logged out. There is also a pop-up window and if the user press down on the key board then the timer resets. I have already done this in my test files, What I am trying to do is apply it to this other code and its a bit tricky. Below you will find my test code.
test1.php
test2.php (pop-up window)
test.js
What I am trying to do is apply the function and the button to this code:
I have tried to put the test2 variable as _h but that didn't work at all. Any help would be much appreciated, thanks!!!
test1.php
PHP Code:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" language="javascript">
var test2
function popup() {
test2=window.open( "test2.php", "myWindow",
"status = 1, height = 300, width = 300, resizable = 0" )
}
</script>
</head>
<body>
<?php
echo '<a href="#" onclick="popup()" >Click Here</a>';
echo '<embed src="logout_operator.wav" autostart="false" id="logout" width="0" height="1" loop="false">';
echo '<script type="text/javascript" language="javascript" src="test.js"></script>';
echo '<script type="text/javascript" language="javascript">
function timeout(logoutSound)
{
var soundLogout=document.getElementById(logoutSound);
soundLogout.Play();
alert("Your session is expired please login again");
location = "http://www.google.com";
}
</script>';
?>
</body>
</html>
PHP Code:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" language="javascript" src="test.js"></script>
</head>
<body>
<script type="text/javascript" language="javascript">
window.onkeydown = handle;
function handle() {
resetTimer();
return true;
}
</script>
</body>
</html>
Code:
var timer = setTimeout("timeout('logout')", 5000); function resetTimer(d) { clearTimeout(timer); if (d!="done"){ if (location.href.indexOf("test2.php")!=-1){ window.opener.window.resetTimer("done"); } else{ test2.window.resetTimer("done"); } } timer = setTimeout("timeout('logout')", 5000); }
Code:
var _h = { mi: function (link, title, ni, qi, width, height, ri) { return '<a href="' + link + '"' + (ri != null ? ' class="' + ri + '"' : '') + ' target="_blank" title="' + title + '" onclick="this.newWindow = window.open(\'' + link + '\', \'' + ni + '\', \'toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=' + width + ',height=' + height + ',resizable=1\');this.newWindow.focus();this.newWindow.opener=window;return false;">' + qi + '</a>'; }
Comment