homepage Welcome to WebmasterWorld Guest from 54.161.155.142
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
Revata




msg:3982170
 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?

 

whoisgregg




msg:3982885
 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.

Revata




msg:3983063
 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.

whoisgregg




msg:3983388
 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