Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Remove iframe from within iframe

Featured Replies

I'm generating an iframe with javascript

 

iframe=document.createElement("iframe");
iframe.setAttribute("src","http://someaddress.co.uk/");
iframe.setAttribute("style","position: fixed; top: 0px; left: 0px; z-index: 99999;");
iframe.setAttribute("width","400");
iframe.setAttribute("frameborder","no");
iframe.setAttribute("height","100%");
iframe.setAttribute("id","myIframeId");
void(document.body.appendChild(iframe));

If there any way I can have a link inside this iframe that removes it from the page?

 

Maybe something like this?

 

<a href="java script:window.parent.document.getElementById('myIframeId').parentNode.removeChild(window.parent.document.getElementById('myIframeId'))">Close</a>

 

Doesn't work?

 

Thanks

  • Author
Im not 100% on what you mean, do you mean you want the link inside the iframe to open in a new browser window??

 

No, my page loads up and the javascript is run that creates an iframe. In that iframe there is some information and a link that says "remove this iframe". When you click it the frame in which the link resides is removed leaving the page as it would have been if the initial javascript had not been run.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.