views:

387

answers:

2

I have a page (A) including a BUTTON with a function close_window() , however when I embed A to my main page (B) using iframe, the close_window() can't work as expected since there is no more window anymore, and I am not able to remove the button from the iframe since A is on another domain (Security issues prevents).

What I want to do is make this button label invisible. And the only way I think is to put a white image just to the place where that button exists on my iframe, externally. is Smthing like that possible? I want the image to be on the top of iframe?

Or do you have any other idea ?

Thanks for helps.

A: 

Actually, JavaScript executed by the container window can manipulate the DOM of the document in the <iframe>. For example, clicking on the button in this page hides the Google Search button in the document in the <iframe>. Note that the JS is quick and dirty, and I've only tested it using Safari:

Container HTML:

<html>
    <head>
        <title>Container</title>
        <script type="text/javascript">
        onload = function () {
            // Listen for a click on the 'remover' button.
            var oRemover = document.getElementById('remover');
            oRemover.onclick = hideGoogleSearchButton;
        }
        var hideGoogleSearchButton = function () {
            var oInnerDoc = document.getElementById('google_frame').contentDocument;
            var aForms    = oInnerDoc.getElementsByTagName('form');
            var oButton   = aForms[0].elements['btnG'];
            oButton.style.display = 'none';
        }
        </script>
    </head>
    <body>
       <button id="remover">Hide 'Google Search' button inside the iframe</button>:
       <iframe src="http://www.google.com/" id="google_frame" />
    </body>
</html>
Richard Turner
Hmm. Looks like this only works in Safari, and can be considered a cross domain security bug.
Richard Turner
A: 

Not working on both internet explorer and firefox. Here is the firebug error:

Permission denied for <file://> to get property HTMLDocument.getElementsByTagName from <http://www.google.com&gt;. anonymous()New%20Te...ment.html (line 12) [Break on this error] var aForms = oInnerDoc.getElementsByTagName('form');\r\n

Well as I understand it is the same reason, the iframe security issues. So I need an external way.

stckvrflw