document.getElementById not working in FireFox

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
fahadb
Posts: 12
Joined: April 1st, 2009, 4:41 am

Re: document.getElementById not working in FireFox

Post by fahadb »

when i assign the same id to both inner and outer object, the page doesnt read the inner object in FF but in IE it runs the outer one fine, in FF its not even showing the flash so not reading the inner one..
fahadb
Posts: 12
Joined: April 1st, 2009, 4:41 am

Re: document.getElementById not working in FireFox

Post by fahadb »

if you check this updated zip file, you will see lot of attempts on getting the value in the flash on FIREFOX, but none of it worked out, please check if you can:

http://www.showtimearabia.com/test/Var/2Objects1ID.zip

Thanks
F.
User avatar
jscher2000
Posts: 11742
Joined: December 19th, 2004, 12:26 am
Location: Silicon Valley, CA USA
Contact:

Re: document.getElementById not working in FireFox

Post by jscher2000 »

You cannot use the same id for two different elements; id must be unique. Since Firefox is assigning the id to the outer <object> then it is not available to identify the inner object, which is the one that actually can work in Firefox.

Since you are using SWFObject, why not let it create one and only one <object> for you? I think that's what it was designed for. Hopefully then you won't have this problem of two <object>s and everything will work as expected.
fahadb
Posts: 12
Joined: April 1st, 2009, 4:41 am

Re: document.getElementById not working in FireFox

Post by fahadb »

hi

The issue has been resolved, the changes were required in the java script as its using the SWFOBJECT, here is the working code below:

Code: Select all

<script type="text/javascript">
      swfobject.registerObject("myID", "8.0.0");

      window.onload = function CountryCode() {
            var obj = swfobject.getObjectById("myID");
            if (obj && typeof obj.SetVariable != "undefined") {
               obj.SetVariable("VariableinFlash", "Value");
            }
         
             };
      </script>


 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="268" height="246" id="myID" name="myID">
                <param name="movie" value="mySWF.swf?" />
                <param name="menu" value="false" />
                <!--[if !IE]>-->
    <object name="myID" type="application/x-shockwave-flash" data="mySWF.swf?" width="268" height="246">
    <param name="swliveconnect" value="true" />
                <!--<![endif]-->
                <!--Non Flash Announcement-->
                Alternate Content Here
                <!--Non Flash Announcement-->
    <!--[if !IE]>-->
    </object>
    <!--<![endif]-->
  </object>


Thanks everyone for helping me out!!!

Fahad.
Post Reply