Welcome to WebmasterWorld Guest from 54.226.238.178

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)

New User

5+ Year Member

joined:Apr 30, 2009
posts: 30
votes: 0


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 Sept 2, 2009 (gmt 0)

Senior Member from US 

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

joined:Dec 9, 2003
posts:3416
votes: 0


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 Sept 2, 2009 (gmt 0)

New User

5+ Year Member

joined:Apr 30, 2009
posts: 30
votes: 0


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 Sept 3, 2009 (gmt 0)

Senior Member from US 

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

joined:Dec 9, 2003
posts:3416
votes: 0


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.

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members