PDA

View Full Version : JavaScript question about focus()


pigghost
08-22-2001, 03:57 PM
Hi...I'm trying to set the focus of an swf in an HTML page using JavaScript...
What I've got works great in IE 5.5 on PC...in Netscape 4.7 I get a JavaScript Error...here's what I have in the HEAD...

<script language="javascript">
function focusMovie(){
window.document.mymovie.focus();
}
</script>

...and I'm calling it in the BODY with

onLoad="focusMovie()"

...and of course I've given the movie the ID="mymovie" in the Object and name="mymovie" and swLiveConnect="true" in the Embed.....

I put together a quick little demonstration...if you use IE 5.5 on PC you should be able to, without clicking the movie first, move the box left and right with the arrow keys...but not with Netscape...this is with PC, not sure what happens on a MAC...

http://www.hotgreen3.com/setFocus.html

Anyone have a clue what the problem is?? I've done searches at several boards and seen hints that this should work, but I can't really find any documentation...not even at MM, although I'm still looking...

Thanks for taking a look...

-pigghost-

pigghost
08-22-2001, 05:59 PM
UPDATE: I thought I'd try to call the function from Flash using 'getURL' and once again IE worked, Netscape 4.7 didn't...but no JavaScript error this time........

...and someone informed me it works in Netscape 6

So I guess to be safe, you need to make sure the movie has focus(by having the user click on it) before asking someone to use keys or type anything in a textfield......

Thanks...

-pigghost-

Jesse
08-23-2001, 05:19 AM
Well as you say it works in IE adn not NS. I've never seen a great version of such scripts which works all-round. The common solution I propose to such a problem is having a flash frame with an Enter button, or someting similar. This is good because it forces manual focus and it also allows users like me, who browse 20 sites at once, to only start your intro/games/whatever when I want.

pigghost
08-23-2001, 06:54 AM
Thanks for your response, Jesse. I think your solution is probably best...

Take care...

-pigghost-