PDA

View Full Version : Error: 'window.document.mymovie.focus' is not a function?


jce1975
12-13-2005, 11:03 PM
I am trying to put the focus onto a flash piece on a html page. I keep getting an error saying that 'window.document.mymovie.focus' is not a function. Here are the code snippets:

<body onLoad="window.document.mymovie.focus();">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,204" width="540" height="433" id="mymovie" name="mymovie">
<param name="movie" value="../swfs/ambulance.swf">
<param name=quality value=high>
<embed src="../swfs/ambulance.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="540" height="433" id="mymovie" name="mymovie"></embed>
</object>

Any help would be greatly appreciated!

- James

_Aerospace_Eng_
12-14-2005, 01:37 AM
Try this instead
<body onload="document.getElementById('mymovie').focus();">

jce1975
12-14-2005, 02:36 PM
Thanks for the response!

I replaced my body tag with this

<body onload="document.getElementById('mymovie').focus();">

, but now I am getting the error,

"document.getElementById('mymovie').focus is not a function". :confused:

Any other suggestions?

- James

_Aerospace_Eng_
12-14-2005, 07:13 PM
You have used the id="mymovie" as well as name="mymovie" more than once, you can only use it one time. Can you post a link to your page please?

jce1975
12-14-2005, 07:22 PM
Here is the link:

http://education.jsc.nasa.gov/brainbites/ambulance/test.cfm

Thanks!

Nischumacher
12-16-2005, 04:08 PM
you can give more then one element the same name... but the id has to be unique...

either give both the elements a different id... say mymovie1 and mymovie2...
and use document.getElementById('mymovie1').focus();"
or document.getElementById('mymovie2').focus();"
according to the requirement...

or get rid of both the id's... and use getElementsByName('mymovie')
this will return both the elements...
access the required element like this...
document.getElementsByName('mymovie')[0].focus();"
document.getElementsByName('mymovie')[1].focus();"

hope this helps...