943,154 Members | Top Members by Rank

Ad:
Feb 9th, 2010
0

Why is getElementById Null?

Expand Post »
I have a very simple flash program that plays music. It consists of a play pause button and a timer that shows the current position of the song. I'm trying to make it possible to pause or play the song using a regular form button.

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <div class="musicplayer_playpause">
  2. <script type="text/javascript">
  3. AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','65','height','68','src','player','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','wmode','transparent','id','flashobject','movie','player','flashvars','id=<?=$cur_songid;?>&type=<?=$_GET["type"];?>&csid=<?=$cur_songid;?>&l=<?=$Arrcntt+1;?>"' ); //end AC code
  4. </script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" id="flashobject" width="65" height="68">
  5. <param name="movie" value="player.swf" allowscriptaccess="always"/>
  6. <param name="quality" value="high" />
  7. <param name="wmode" value="transparent" />
  8. <param name="id" value="flashobject" />
  9. <param name="swliveconnect" value="true" />
  10. <embed src="player.swf" name="flashobject" width="65" height="68" quality="high" allowscriptaccess="always" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent" swliveconnect="true" ></embed>
  11. </object>
  12. </noscript></div>

Here's the Javascript function, which I put in the section:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <script type="text/javascript">
  2. function Pause() {
  3. var flash = document.getElementById('flashobject');
  4. flash.PlayPause;
  5. }
  6. </script>

And finally here's the button I'm using:

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <form>
  2. <input type="button" value="Play" name="Play" onClick="Pause();">
  3. </form>

When I click the button, Firefox's error console says "Flash is null" What am I doing wrong?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
jaydee123 is offline Offline
1 posts
since Feb 2010
Feb 10th, 2010
0
Re: Why is getElementById Null?
You have the object inside a <noscript> block so it's not being rendered if you have javascript enabled.
Sponsor
Reputation Points: 520
Solved Threads: 268
Code Monkey
ShawnCplus is offline Offline
1,564 posts
since Apr 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: PrototypeJS onInteractive problem
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: at a state of desperation please help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC