Skip to content Skip to sidebar Skip to footer

How To Add Css Property To Elements Outside Iframe?

I'm sorry if this wasn't the right place to ask. I'm having trouble figuring this one out. What I'm trying to do is removing the demo bar provided by marketplaces like themeforest

Solution 1:

The Answer is No. It is not possible to modify dome elements outside iframe by a script on site in iframe.

Reason: Since The Marketplace website is Accessing your Demo Site within iFrame at thier server. Like how you embed a YouTube Video on your Page and Specify a Heading above it etc, does youtube or google map ever try to change their container styles? do they ever change the heading you wrote above the embed code? Thats it

Solution 2:

You cannot (due to the Cross Site Scripting - http://en.wikipedia.org/wiki/Cross-site_scripting) as it is a separated document. But what You can do is to use Web Messenging: http://en.wikipedia.org/wiki/Web_Messaging to affect JS/CSS within the iframe (but this will require actions on both sides).

Solution 3:

If you can execute Javascript from within an iframe you can change the elements outside of it with the Window parent Property. Example usage:

parent.document.body.style.backgroundColor = "red";

changes the background of the <body> outside of the iframe.

Post a Comment for "How To Add Css Property To Elements Outside Iframe?"