/    Sign up×
Community /Pin to ProfileBookmark

Trying to get SWFs to load after HTML using JS

I have tried many approaches and have no luck. ANY help on this would be appreciated as I have been trying to get this to work for a week. I am no JS guy so please “be-gentle” but I like direct!:o

NOTE: I prefer not to use the SWFobject.js to load my SWFs

Approach ONE: Rewrite to get rid of comment tags.

[CODE]
<div id=”myFlash”>
<!–<object classid=”clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″ width=”1054″ height=”453″ id=”FlashID” title=”mymovie”>
<param name=”movie” value=”flash/banner.swf” />
<param name=”quality” value=”high” />
<param name=”wmode” value=”transparent” />
<param name=”swfversion” value=”8.0.35.0″ />

<param name=”expressinstall” value=”Scripts/expressInstall.swf” />

<object type=”application/x-shockwave-flash” data=”flash/banner.swf” width=”1054″ height=”453″>

<param name=”quality” value=”high” />
<param name=”wmode” value=”transparent” />
<param name=”swfversion” value=”8.0.35.0″ />
<param name=”expressinstall” value=”Scripts/expressInstall.swf” />

<div>
<h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
<p><a href=”http://www.adobe.com/go/getflashplayer”><img src=”http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif” alt=”Get Adobe Flash player” /></a></p>
</div>

</object>

</object>–>
<script language=”javascript” type=”text/javascript”>

function reWriteFlash(){

var myHTML = document.getElementById(“myFlash”).innerHTML;

myHTML = myHTML.replace(“<!–“,””);

myHTML = myHTML.replace(“–>”,””);

document.getElementById(“myFlash”).innerHTML = myHTML;

}

</script>
</div>

[/CODE]

Approach TWO: OnLoad ReWrite…

[CODE]
<script language=”javascript”>
<!–//hide

//function to write in flash object when page loads.
function writeFlash(){
//place your flash object tags inside a variable
// i’m gonna split it up a bit here, just for my own purposes of ledgability, and checking for errors… not really necessary.
var flashOut='<OBJECT classid=”clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″ codebase=”http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0″ WIDTH=”550″ HEIGHT=”100″ id=”javascripttest” ALIGN=””>’;
flashOut=flashOut+'<PARAM NAME=movie VALUE=”javascripttest.swf”>’;
flashOut=flashOut+'<PARAM NAME=quality VALUE=high>’;
flashOut=flashOut+'<PARAM NAME=bgcolor VALUE=#CC6600>’;
flashOut=flashOut+'<EMBED src=”javascripttest.swf” quality=high bgcolor=#CC6600 WIDTH=”550″ HEIGHT=”100″ NAME=”javascripttest” ALIGN=”” TYPE=”application/x-shockwave-flash” PLUGINSPAGE=”http://www.macromedia.com/go/getflashplayer”>’;
flashOut=flashOut+'</EMBED></OBJECT>’;
//create a layer tag to place your flash object into, and to position your flash object
//document.write(“<layer name=’flashLayer’ top=300 left=100>”+flashOut+”</layer>”);
//the above didn’t seem to work… so i’ll try:
//document.write(“<layer name=’flashLayer’>”+flashOut+”</layer>”);
//document.layer.flashLayer.top=500;
//still no go… maybe try it wil div… and style:
document.write(“<div name=’flashLayer’ style=’position:absolute; left:100px; top:300px;’>”+flashOut+”</div>”);
//this one seems to work in ie… but I have no way to control it and thr inline styles are going to reap havoc on my CMS.

}

//–>
</script>
<body onLoad=”writeFlash()”>

[/CODE]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@mityaSep 18.2009 — document.write is not an ideal tool for putting out code to the page. It's more for writing simple text. If you want to modify code after load, you should really be DOM scripting. This is a whole field in itself and deserves your time doing a bit of reading. Here's an example:

[CODE]var newTag = document.createElement('div');
newTag.className = "myclass";
newTag.id = "myid";
newTag.appendChild(document.createTextNode("Hi, everyone!"));
document.appendChild(newTag);[/CODE]
×

Success!

Help @mabron spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...