Jump to content

Help plz!


errietta

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...