homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

focus() problems
focus() doesnt work in Safari, Chrome & Opera

 6:56 pm on Sep 1, 2009 (gmt 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 Sep 2, 2009 (gmt 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 Sep 2, 2009 (gmt 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 Sep 3, 2009 (gmt 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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved