errietta Posted May 11, 2008 Share Posted May 11, 2008 Hey is there a way to alert something onblur ONLY ONCE? I mean if the page loses focus it alerts something but only one time.. ive tried soem things but it does that every time the page loses focus and thats annoying help plz Link to comment Share on other sites More sharing options...
Synook Posted May 11, 2008 Share Posted May 11, 2008 You can use a global boolean to track whether its been blurred yet var blurred = false;window.onblur = function() { if (!blurred) { alert("The is the first time you have blurred the window!"); blurred = true; }} Link to comment Share on other sites More sharing options...
errietta Posted May 11, 2008 Author Share Posted May 11, 2008 ty ty ty and ty! Link to comment Share on other sites More sharing options...
Jesdisciple Posted May 12, 2008 Share Posted May 12, 2008 You could also erase the onblur code so it's not executed anymore (a very small optimization, but still...): window.onblur = function() { alert("This is the first time you have blurred the window!"); window.onblur = null;} Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.