Reputation: 155
I have a HTML page with a dropdown list and when I select an option, an iframe is opening containing another HTML page. Inside the second HTML page I have button and when I click the button I want to open a link (inside the iframe). When I run only the second page it's working, but when I run the first page (with the dropdown list) it's not working anymore.
Does anyone knows why is this happening and how can I fix it?
Here is an example of code for the first page:
function Ex(form) {
var myindex = Example.drop.selectedIndex
if (Example.drop.options[myindex] != "0") {
window.open(Example.drop.options[myindex].value, target = "iframe1");
}
}
<form name="Example">
<select name="drop" onchange="Ex(this.Example)">
<option value="about:blank">Select something...</option>
<option value="Page1.html">Page1</option>
<option value="Page2.html">Page2</option>
<option value="Page3.html">Page3</option>
</select>
<iframe id="iframe1" name="iframe1" src="about:blank" align="top" height="900" width="1000" style="border:none; "></iframe>
</form>
And here is an example of code for one of the pages that open inside the iframe:
<img src="http://focusdesignz.com/wp-content/uploads/2015/07/picture_1436728897.jpg"/>
<input type="button" onclick="location.href='http://www.google.ro'" value="Some Button"/>
Upvotes: 0
Views: 197
Reputation: 1219
Your code works if not in a iframe.
In a iframe, error message : [Error] Refused to display 'https://www.google.ro/?gws_rd=ssl' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'. (button.html, line 3).
Google.ro seems to refuse being iframed.
If you use another URL than Google.ro, get sure your Cross-Domain policy is ok. The URL must agree with being displayed in an iFrame.
Upvotes: 1