Append Meta Tag To The Head Of The Main Document From Iframe
So I've got an issue where i've made a document responsive but it's displayed in an iframe which where the parent document has the wrong meta tag. I set up a test to see if i coul
Solution 1:
You can do it, but only if the domain of the iframe is the same of the top document's domain.
Just change your code to:
window.parent.document.getElementsByTagName('head')[0].appendChild(viewPortTag);
Solution 2:
Use window.parent.document
instead of document in iframe.html. Assuming both files are on the same domain.
var viewPortTag=document.createElement('meta');
viewPortTag.id="viewport";
viewPortTag.name = "viewport";
viewPortTag.content = "width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;";
window.parent.document.getElementsByTagName('head')[0].appendChild(viewPortTag);
Post a Comment for "Append Meta Tag To The Head Of The Main Document From Iframe"