Reputation: 10839
I'm currently developping an overlay and have an issue with it. In fact my overlay is materialized by an iframe that i'm injecting in all the web page.
Overlay : http://img641.imageshack.us/img641/691/toolbarm.png
I would like just hide it when i press on the close button at the right side.
Here is my function that inject the overlay (iframe) :
injectOverlay: function()
{
var body = $('body'),
OverlayURL= chrome.extension.getURL("overlay.html"),
iframe = $('<iframe id="OverlayFrame" scrolling="no" src="'+OverlayURL+'">');
body.append(iframe);
}
And here is the code to hide it (but it didn't work) :
function hideOverlay()
{
var iframe = document.getElementsByName('iframe')[0];
iframe.parentNode.removeChild(iframe);
// $('#OverlayFrame', window.parent.document).remove();
alert('Overlayclosed');
}
Upvotes: 0
Views: 7624
Reputation: 89
If you just want to hide it, you dont need to remove it, perhaps
jQuery('#OverlayFrame').toggle();
Upvotes: 0
Reputation: 3526
Try any of the following options :
$("iframe").remove()
$('#OverlayFrame').remove()
$('iframe#OverlayFrame').remove()
you can use detach()
/ hide()
instead of remove().
Upvotes: 0
Reputation: 2454
Since you are using jquery anyway, just write
var fram = $("iframe").get(0);
fram.parentNode.removeChild(fram);
That will only work if you only have 1 iframe on the whole page. Otherwise you could specify the selector in the normal jquery fasion (iframe#id or whatnot).
Upvotes: 1