views:

14

answers:

1

I've got a Jquery function that I wrote which blacks out the screen after a certain amount of inactivity, creates a pop-up that allows the user to click a button to stay logged in, and logs them out (closing the application window) if they do not respond in time.

We don't technically use master pages, but we do have a parent page in which our header, footer and nav reside, and my Jquery code is called from that window.

My problem is that if one is working in a child window, the parent window doesn't recognize that the system is in use, and will automatically engage at the allocated time.

I know it doesn't exist, but I guess I'm looking for a window.child.settimeout or something like that. Thanks in advance for your time and any ideas.

A: 

Simply have your child window report it's activity to the parent window.

In the parent window, add a function:

    window.reportChildActivity = function() {
        resetLogoffTimer();
    };

And then in the child window, call that function:

    window.parent.reportChildActivity();

whenever you detect user's activity.

Fyodor Soikin
Thanks, that makes sense. I guess I'm not real clear, though, on how best to have the child window detect activity. I was hoping to avoid having to intercept mouse clicks, key strokes and the like.
Mike
Well, from your question, I got the idea that you DO detect activity in the parent window somehow, don't you? Just do the exact same thing for the child window.
Fyodor Soikin
My current code doesn't explicitly detect activity. Previously I had the code loaded in a header file that loads on every page - I guess I could set up the reportChildActivity() call there.
Mike
I guess the issue with that approach would be that typing and mouse clicks wouldn't "count" as keeping the window alive.
Mike
Well, if I wanted to detect the user's activity, I would go just that way: handle keystrokes and mouse clicks (or maybe even mouse moves). It's not that hard: just attach a handler to `<body>`
Fyodor Soikin
Fyodor, I tried your approach. I have this function in the parent window:<script language="javascript" type="text/javascript"> function window.reportChildActivity() { SESSION_ALIVE = true; window.setTimeout("pop_init()", SESSION_TIME); } </script>And this in the child window:<script type="text/javascript"> $(document).bind("mousedown keydown blur", function() { window.parent.reportChildActivity(); });</script>My issue now is that the timer is not being reset. The function is called by the event handler.
Mike
No matter how much I click or use keys in the child window, my Jquery timeout code is called when SESSION_TIME runs out the first time. And then I get multiple Jquery windows in my page telling me to click to continue. It's like the events are being buffered and when they fire these windows are all being spawned multiple times.Do you see from this what I'm doing wrong? Thanks!
Mike
Ummm... This is NOT my approach. Look at my code carefully and compare to yours.
Fyodor Soikin