I have a bookmarklet that opens an frame in any web page. The iFrame is opened from a parent js document, which also has a method to close it up. My problem is that the close method can only be accessed from the window, but not the iframe. The question is: How do I access from the iframe the js methods of the parent document, to the point, how do close the iframe?
Inside the iframe you have a 'parent' object which is the window. This means that if the iframe has an id 'myiframe' you can access the window using: document.getElementById('myiframe').parent Code (markup): I don't know how you wanna 'close' the iframe but i guess removing it will do the job. You can use something like that (presuming it still has the id 'myiframe'): document.body.removeChild(document.getElementById('myiframe')); Code (markup): or the long way to do the same... document.getElementById('myiframe').parent.removeChild(document.getElementById('myiframe')); Code (markup):