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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic removal of SWF

Status
Not open for further replies.

mikemedia

Programmer
Apr 28, 2006
39
US
I have a short intro SWF embeded within a <div>.

Once played, I want it to go away.

I'm trying a javascript getElementbyID and remove, but as usual am thwarted by my poor syntax skills.

var vanish = document.getElementById('intro.swf');
vanish.remove

Assistance appreciated.
 
Thanks for answering BillyRay.

No, it didn't work.
Let me give you a bit more detail.

Firstly, I'm forced by my IP to employ an ugly JS workaround to even display the Flash. Basically my JS file is a sequence of document.write lines of HTML. The HTML is the standard fare that Macromedia uses to embed and display a SWF. Here's the whole ballywick (with your input included):

Thanks again!

Code:
// JavaScript Document
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="[URL unfurl="true"]http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"[/URL] width="760" height="50">');
document.write('<param name="movie" value="intro.swf">');
document.write('<param name="quality" value="high">');
document.write('<embed src="intro.swf" quality="high" pluginspage="[URL unfurl="true"]http://www.macromedia.com/go/getflashplayer"[/URL] type="application/x-shockwave-flash" width="760" height="50"></embed>');
document.write('</object>');

document.write('<div id="flaLayer" style="position:absolute; left:94px; top:110px; width:760px; height:50px; z-index:1">');
document.write('<div align="right"><img src="images/swfsubst.gif" width="5" height="5"></div>');
document.write('</div>');

var vanish = document.getElementById('intro.swf');
vanish.parentNode.removeChild(vanish);
 
Of course that's not going to work - you have nothing with an ID of "intro.swf".

I suggest putting a container around your Flash, giving that a real ID, and using that.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
BillyRay:
I really am sorry to trouble you with this again.
All I can do is plead ignorance and ask for your additional assistance with this.

I have tried to employ your solution. I have read, books, forums, and source code. I really wanted to discover the answer on my own so that I would actually learn some syntax.

I am familiar with the tag <dim>. I am not so good with the DOM getElementbyID.

Exactly how to I put the Flash "in a container"?

Thanks yet again.
 
<dim>"? funny typo ;-)

Before this line:

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

add this line:

Code:
document.write('<div id="introSWF">');

and after this line:

Code:
document.write('</object>');

add this line:

Code:
document.write('</div>');

This will add a "div" element around your flash movie. Then you should be able to remove the flash with this:

Code:
var vanish = document.getElementById('introSWF');
vanish.parentNode.removeChild(vanish);

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top