[RESOLVED]I have java script timeout counter, on iis 6 , it does show timeoutcounter but on IIS7 showing NaN

I have the following when used on IIS 6.0 working with session timeoutcounter within a text box, but on IIS 7 showing NaN, can you please advise what may be going wrong or i need to update.

Thanks a lot for the helpful info.

// TimeOut Counter functions
function startSessionTimeoutCounter()
{
var e;

//window.clearInterval (counter);
//counter = null;
//y = 0;
e = window.parent.frames[0].document.getElementById("txtTimeOut");
if (e!=null) {
x = parseInt(e.value,10) * 60;
}
e = window.parent.frames[0].document.getElementById("txtTimeOutMessage");
if (e!=null) {
timeoutmessage = e.value;
}
window.parent.frames[0].document.getElementById("txtcounter").value = x;

}

I’m a bit confused as to exactly what you are trying to do. It might be a bit easier if we had some kind of context or example markup. I tried to clean things up a bit, however I wasn’t sure if this is going to be exactly what you are looking for :

function startSessionTimeoutCounter() {
    // Define your x variable (since it is being reused)  
    var x;
    // Find your txtTimeOut element
    var timeOut = window.parent.frames[0].document.getElementById("txtTimeOut");
    // If it exists
    if (timeOut !== undefined) {
         // Get the value from it and multiply it by 60
         x = parseInt(e.value,10) * 60;
         // Store your value in the counter
         window.parent.frames[0].document.getElementById("txtcounter").value = x; 
    } 
    
    // Find your txtTimeOutMessage element
    var timeOutMessage = window.parent.frames[0].document.getElementById("txtTimeOutMessage");
    // If it exists
    if (timeOutMessage !== undefined) {
        timeOutMessage.value = e.value;
    } 
}

I would highly recommend using the Javascript
debugger; keyword
in this case. Place it in the beginning of your function, open the Developer Tools (F12) within your browser and trigger the function. You should be presented with a Visual Studio-like debugger that you can use to step through your existing
code and see where your problem might be occurring at.

function startSessionTimeoutCounter() {
    // Define a debugger
    debugger;
    // Code omitted for brevity
}

Leave a Reply