Click to See Complete Forum and Search --> : how to remove embed element?
vcorn4
01-09-2004, 09:13 AM
i use document.body.appendChild(embedNode)
where embedNode = document.createElement("embed");....
now i want to remove it after 5 seconds, i try use setTimeout then use document.body.removeChild(embedNode);
but can't get it removed
anyone know how to?
Thx alot
fredmv
01-09-2004, 09:17 AM
It's not working because embedNode isn't a reference to that element. You'll have to do something such as assign it an id attribute and then remove it like this:document.body.removeChild(document.getElementById('foo'));Where foo is the id attribute of the element.
Khalid Ali
01-09-2004, 09:21 AM
removeChild may not work in IE,for IE use
nodeToBeRemoved.removeNode(true);
vcorn4
01-09-2004, 09:31 AM
actually i'm using IE,
it is so funny, removeChild works when i use object, but doesn't work with embed,,,very strange
and regarding to fred post by using reference
i do this
embedNode.setAttribute("id","flashMov");
then to remove i use:
document.body.removeChild(document.getElementById("flashMov");
this one also doesn't work so khalid is correct, but i feel strange, i can use removeChild with Object element , but this Object element is not created using document.createElement....i straight away write the <object...bla bla bla..
why is it so??
vcorn4
01-09-2004, 09:36 AM
hi khalid, i also can't use the code you suggest
maybe if you guys have time, try my code...
code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>testing</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
var obj;
function begin(){
var mulai = setTimeout("remove()",5000);
}
function again(){
var lagi = setTimeout("removed()",5000);
}
function removed(){
document.body.getElementById("flashMov").removeNode(true);
}
function remove(){
document.body.removeChild(flashMov);
var embedNode = document.createElement("embed");
embedNode.setAttribute("id","flashMov");
embedNode.setAttribute("src","intro1.swf");
embedNode.setAttribute("height","25%");
embedNode.setAttribute("width","25%");
embedNode.setAttribute("quality","high");
embedNode.setAttribute("type","application/x-shockwave-flash");
embedNode.setAttribute("pluginspace","http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash");
document.body.appendChild(embedNode);
}
</script>
</head>
<body bgcolor="#000000" onLoad="begin();">
<OBJECT id="flashMov" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" STYLE="POSITION: absolute; HEIGHT:27%;WIDTH:25%;TOP:330;LEFT:325;VISIBILITY:VISIBLE;">
<param name="movie" value="intro1.swf">
<param name="play" value="true">
<param name="loop" value="true">
<param name="quality" value="best">
</OBJECT>
</body>
</html>
vcorn4
01-09-2004, 10:06 AM
so sorry guys, solved it now,
in IE we can also use removeChild, so khalid is wrong :D
i use document.body.removeChild(document.getElementById('name'));
it works well...just now i forget to call the function to remove...that's why it doesn't remove...
thx khalid and fred