Forum Moderators: open

Message Too Old, No Replies

document.write FLASH?

         

ShawnJC

6:25 pm on Feb 27, 2004 (gmt 0)

10+ Year Member



Ok, I know it's possible to write Flash with the document write command, because I've done it before...but I've gone round and round this script, anyone see what I'm doing wrong? It works fine if in the document.write section I put HTML for an image or something, but my Flash won't show up.

//Set NS6 to false in case it is skipped in the if (!IE4)
NS6=false;

//detect Internet explorer 4 - If document.all returns TRUE, then program
//is compatible for IE4
IE4=(document.all);

//If it's not IE4 detect for Netscape six. If getElementByID returns ture, program
//is compatible for Netscape 6
if (!IE4) {
NS6=(document.getElementById);
}

//detect Netscape 4 - If document.layers is TRUE, program is compatible for NS4
NS4=(document.layers);

function createLayer (name, xpos, ypos, content) {
//***********************************************************************************

if (NS4) {
document.write('<LAYER NAME="'+name+'" LEFT="'+xpos+'" TOP="'+ypos+'">');
}

if ((IE4) ¦¦ (NS6)) {
document.write(' <div id="'+name+'" style="position:absolute; left: '+xpos+
' ; top: '+ypos+
' ;"> ' );
}

//*************************************************************************************

/*
I've tried doing it this way as well:

document.write ("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'");
document.write ("codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='350' height='300'>");
document.write ("<param name='movie' value='cannonshoot.swf'>");
document.write ("<param name='quality' value='high'>");
document.write ("<param name='wmode' value='transparent'>");
document.write ("<embed src='cannonshoot.swf' width='350' height='300' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' wmode='transparent'>");
document.write ("</embed></object>");
}

And also have tried the following way:*/

var cannonInfo = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="350" height="300"><param name="movie" value="cannonshoot.swf"><param name="quality" value="high"><param name="wmode" value="transparent"><embed src="cannonshoot.swf" width="350" height="300" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed></object>';
document.write (cannonInfo);

//*************************************************************************************
if (NS4) {
document.write('</LAYER>');
}

if ((IE4) ¦¦ (NS6)) {
document.write('</DIV>');
}

}

DrDoc

6:28 pm on Feb 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to Webmaster World!

Pardon me for asking a perhaps dumb question... but, is your flash file uploaded, and do you have the right path to it?

ShawnJC

6:33 pm on Feb 27, 2004 (gmt 0)

10+ Year Member



Yea, the flash works fine. Funny thing is if I take the exact code in the area where I'm using document.write to put it in the layer, and just post it as javascript tag in the body of an HTML document, it works fine. It must have something to do with the fact that it is on a layer....odd though that other HTML stuff works fine when using document.write on that layer script.

ShawnJC

6:33 pm on Feb 27, 2004 (gmt 0)

10+ Year Member



Oh, and thanks for the welcome!

DrDoc

6:34 pm on Feb 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A particular browser that you have the problem with?

ShawnJC

6:47 pm on Feb 27, 2004 (gmt 0)

10+ Year Member



Well, right now I'm testing it with IE 6, but when finished it needs to works with all newer browsers. I understand the problem with transparent Flash and earlier browsers so I'm not trying full compatibility for the Flash contenet with them.

DrDoc

6:50 pm on Feb 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Maybe the problem is the broken <object> tag?

document.write ("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'");
document.write ("codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='350' height='300'>");

Consider making those one single line.

ShawnJC

7:05 pm on Feb 27, 2004 (gmt 0)

10+ Year Member



I found a solution...I have to put this in place of the document.write commands:

function writeF(){
document.getElementById(name).innerHTML = content;
}
window.onload=writeF;
}

where 'content' is all the object tags for the Flash movie.