javascript - Blocked iframe due to mismatch protocols -
i trying send value parent window frame on button click
event shows error on console
uncaught securityerror: blocked frame origin "http://localhost:53838" accessing frame origin "null". frame requesting access has protocol of "http", frame being accessed has protocol of "file". protocols must match.
on following line:
window.parent.setupframe();
i have following code in parent container:
<!doctype html> <html> <head> <script> function setupframe() { var frame = window.frames['myframe']; $('#btn-violet').click(function () { frame.changetheme(2); }); } </script> </head> <body> <iframe id="myframe" width="100%" height="300px" src="http://localhost:53838/" name="iframe_a"></iframe> <input type="button" value="bisque theme" id="btn-bisque" /> <input type="button" value="violet theme" id="btn-violet" /> </body> </html>
and code inside frame looks this:
<script> function init() { window.parent.setupframe(); return true; } function changetheme(id) { if (id == 1) { $('#customstyle').attr('href', '/content/stylesheet1.css'); } else { $('#customstyle').attr('href', '/content/stylesheet2.css'); } } </script>
if parent page served through file problem. cannot mix file page http nested frame. should load iframe file well.
Comments
Post a Comment