Results 1 to 2 of 2

Thread: Trying to get SWFs to load after HTML using JS

  1. #1
    Join Date
    Sep 2009

    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!

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

    Approach ONE: Rewrite to get rid of comment tags.
    <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="" />
                                    <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="" />
                            <param name="expressinstall" value="Scripts/expressInstall.swf" />
                  <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>
            <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;
    Approach TWO: OnLoad ReWrite...

    <script language="javascript">
    	//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">';
    		//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>");
    		//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.
    <body onLoad="writeFlash()">

  2. #2
    Join Date
    Oct 2003
    Andover, UK
    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:

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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center