Forum Moderators: open
With the below code, Firefox triggers the onBlur event twice when another window is clicked on, and once after clicking the button and then returning focus back to the page. It is also triggered twice if you put focus in the address bar or google search bar.
Internet Explorer triggers the onBlur event when the button is clicked, when the textarea is clicked, when another window is clicked, and when the address bar is given focus.
The end goal is to have this code in a popup with no address bar, so that problem will be factored out. When the popup opens, the location of the parent will go to another site, so I won't be able to rely on code in the parent browser (such as detecting when the parent receives focus).
If anyone has any ideas, or can even post other conditions under which this focus problem occurs, it will help us all out.
<html>
<head><script type="text/javascript">
function doBlur() {
var status = document.getElementById('status');
var currentValue = status.innerHTML;
status.innerHTML = currentValue + 'window has been blurred ';
}
</script></head>
<body onblur="doBlur();"><form name="form">
<input type="button" value="I am a button" />
<textarea>here is some text</textarea>
</form><b>Status:</b>
<div id="status"></div></body>
</html>