Reputation: 1097
I have this function that creates a "frame" or something like a frame and i want to delete it.
Here is the code for the create:
function disableIframe()
{
var iframe = document.getElementsByTagName('iframe')[0];
d = document.createElement('iframe');
var width = iframe.offsetWidth;
d.style.width = width + 'px';
var height = iframe.offsetHeight ;
d.style.height = height + 'px';
var top = iframe.offsetTop;
d.style.top = top + 'px';
var left = iframe.offsetLeft - 140;
d.style.left = left + 'px';
d.style.position = 'absolute';
// d.onclick="event.cancelBubble = true;"
d.style.opacity = '100';
d.style.filter = 'alpha(opacity=0)';
d.style.display="block";
d.style.background = 'black';
d.style.zIndex = '100';
d.id = 'd';
d.tagName = 'd';
iframe.offsetParent.appendChild(d);
}
I tried to delete the frame with this function:
document.getElementById('d').removeChild();
but it didn't work. how i can find it and delete it? It's suppose to block a web-frame until the time is over so that no one can click on the frame. So it creates a frame over the web-frame and I have a function to delete this frame because after sometime I need to be able click again on the original frame.
Upvotes: 0
Views: 1847
Reputation: 26
try this( A.removeChild(B).A is parent node of B, B is the node to delete)
var node = document.getElementById("d");
if (node.parentNode) {
node.parentNode.removeChild(node);
}
Upvotes: 1
Reputation: 11807
try this
var ele = document.getElementById("d");
ele.outerHTML = "";
delete ele;
or
var ele = document.getElementById('d');
ele.parentNode.removeChild(ele);
Upvotes: 1