Welcome to WebmasterWorld Guest from 54.167.185.18

Forum Moderators: open

Message Too Old, No Replies

focus() problems

focus() doesnt work in Safari, Chrome & Opera

   
6:56 pm on Sep 1, 2009 (gmt 0)

5+ Year Member



Ive got a set of javascript commands that fire off from a link that look like this:

<a href="Javascript:top.content.fplayer.player.sendEvent('LOAD', 'mediafiles/{$row_creditsList['flv']}'); top.content.fplayer.player.sendEvent('PLAY')">

I want to add a focus command to the end so that the player is in focus and the keyboard shortcuts native to the player can be utilized. So I tried this:

<a href="Javascript:top.content.fplayer.player.sendEvent('LOAD', 'mediafiles/{$row_creditsList['flv']}'); top.content.fplayer.player.sendEvent('PLAY');top.content.fplayer.player.focus()">

which works in IE and FF but not in Safari, Opera, and Chrome. :(

I tried setting a time delay [in an onclick and inline] to the focus function thinking it wasn't firing last somehow but that didn't seem to change anything. I also tried document.getElementById('') to handle it and that failed as well. Do these 3 browsers handle focus differently than others? or is the way a series of JS commands are executed?

7:05 pm on Sep 2, 2009 (gmt 0)

WebmasterWorld Senior Member whoisgregg is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Perhaps the .focus() should be on something higher up in the DOM? Like top.content.fplayer.focus()?

I know that Safari has security restrictions about setting .focus on certain elements because of security concerns.

11:17 pm on Sep 2, 2009 (gmt 0)

5+ Year Member



Thanks again for your response gregg.

Yeah, I had tried that. tried adding ".document" at the page level too and nothing really seemed to work.

might be the security thing. Seems a bit odd tho that all 3 browsers are faulting.

2:52 pm on Sep 3, 2009 (gmt 0)

WebmasterWorld Senior Member whoisgregg is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Could you perhaps have the object that's receiving the LOAD event put .focus() on itself when it receives a LOAD event?

I suspect that would get around any security issues, as well as removing any possible ambiguity about pointing to the right element.