I’m doing an Android Web catalog, and for that reason I had to use iframes. I wanted to ask, however, is it possible to click a button in an iframe and make the code work in the main page?
This is the code I have:
function initFastButtons() {
new FastButton(document.getElementById("CloseButton"), runclose);
new FastButton(document.getElementById("OpenButton"), runopen);
};
function runclose() {
$('.full-preview-viewer').hide();
};
function runopen() {
$('.full-preview-viewer').show();
};
And this is what a button in an iframe looks like:
<input id="OpenButton" type="image" src="products/special/product1.png" name="image" width="336" height="593"></input>
Thanks everyone 🙂
You can move the definitions for “runclose()” and “runopen()” to your parent window (the document that is creating the iframe). Then, in your iframe you can modify your initFastButtons() setup to reference those functions as “parent.runclose” and “parent.runopen”. Note that normally this sort of thing is limited when the pages are not requested from the same domain.
Consider these two pages, “inner.html” and “outer.html”:
outer.html:
inner.html: