Forum Moderators: open

Message Too Old, No Replies

window.onblur problem with Mozilla/firefox

         

warp_fr

11:53 pm on Jan 21, 2005 (gmt 0)

10+ Year Member



Does anyone has trouble using:
window.onblur = function(){doSomething();} with Mozilla/firefox 1.0?
Considering, my main page being some kind of image thumb gallery. When you click a thumb, javascript open a popup window that shows the image at big size. There are couple of buttons associate to js functions to navigate throught images : previous, next, last, first, back to thumbs with auto update main page...and a slideshow option. When slideshow activate (on/off button), you can still use all the nav buttons like last or first image, but it will automatically stop slideshow if you use the back to thumb gallery button. I want it to stop too if you just leave focus from popup window like watching another page or going back to thumb gallery without using the back to thumb button, so I used :
window.onblur = function(){stopSlideShow();} in the popup. It does work very well in IE or Opera, but in Firefox, when slideshow playing if I click any nav buttons, like going to first image, slideshow will just stop. It looks like clicking on the button, steal focus from the window and onblur launching stopSlideShow(). I'm sure the problem is coming from window.onblur but can't figure it out. I try using a timeout like this, but didn't worked either :
window.onblur = function(){killFocus=setTimeout('stopSlideShow();',20);}
then using clearTimeout(killFocus) in any function button related that could steal the focus.

warp_fr

1:45 pm on Jan 23, 2005 (gmt 0)

10+ Year Member



None having problem with that?!
I readed some posts about Mozilla having a known bug with blur event but it doesn't seem to be related to my problem here.
I believe it's all about links stealling the focus from window they are in, but can't find a way to go around it.
I was wondering too why do I have to use this form :

window.onblur = function(){stopSlideShow();}

instead of this :

window.onblur = stopSlideShow();

I have tested with 2nd form but it just doesn't work in either IE, Opera or Mozilla.

kaled

2:03 pm on Jan 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



window.onblur = stopSlideShow; should work I think (note the absence of brackets). However, this is unlikely to solve your problem with Firefox.

The syntax above assigns an address to the onBlur event. If you include the brackets, the result of the function call is assigned to onBlur, which is meaningless.

This syntax may only work if stopSlideShow is declared above - you should check that but I think it's ok.

Kaled.