Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change embed src using javascript

Status
Not open for further replies.

deluxmilkman

Programmer
Sep 26, 2007
17
0
0
JP
I'm trying to change embed src using document.getElementById.
what am i missing?

HTML:
<script language="JavaScript" type="text/JavaScript">

myDate = new Date();
myTD = myDate.getTimezoneOffset();
alert(myTD);
if ((myTD >= 180) && (myTD < 480)){
document.getElementById('localswf').setAttribute('src','one.swf');
}else if((myTD >=180) && (myTD < 180)){
document.getElementById('localswf').setAttribute('src','two.swf');
}else if((myTD >= -540) && (myTD < -180)){
document.getElementById('localswf').setAttribute('src','three.swf');

}else{
document.getElementById('localswf').setAttribute('src','four.swf');
}

</script>



</head>
<body>
<div> 
  <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="[URL unfurl="true"]http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0"[/URL] width="105" height="105  ">
    <EMBED src='one.swf' name="localswf" id="localswf" quality="high" pluginspage="[URL unfurl="true"]http://www.macromedia.com/go/getflashplayer"[/URL] type="application/x-shockwave-flash" width="105" height="105"></EMBED></OBJECT>
</div>

</body>


thanx
 
I believe i answered this question in your last post. Did you try what I recommended? I read up on your issue as well cause the question stumpped me. It seems that embed isn't one of those tag that you can easily work with via javascript.
What your trying to do, even if your syntax is correct, from what I read, has presented problems to others. Try going the innerhtml route rewriting a divs content with that of your object/embed tags. Other than that I suggest your try the asking in the flash forum. Even though it is a javascript question I'm sure they could shed somelight on dynamically loading flash movies. Maybe your issue could solved via action script.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top