Search code examples
javascripthtmlmeta

window.parent.document.getElementsByTagName not working


var metaTags = window.parent.document.getElementsByTagName("meta"); console.log("hello"+metaTags.length);

My script is running in an iframe and I am not able to access the parent documents meta tags.The funning thing is nothing is getting printed on console.Not even Hellonull or something.

Thanks in advance Swaraj


Solution

  • I am pretty sure you cannot execute cross frames/domains. If the domains match, you can do this, but if not, then it is a security issue that blocks it. Here is an example of doing so when the domains are the same: Getting parents document from iFrame