How to add CSS property to elements outside iframe?

落花浮王杯 提交于 2019-12-24 08:57:42

问题


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 or mojothemes within my own demo site.

But since what appears in the marketplace's live demo of a theme is fetched, it appears within an iframe inside of their site.

I've tried asking in their forums but no one has been helpful.

Is there any way to do about this? An example done in a marketplace would be great.


回答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




回答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).



来源:https://stackoverflow.com/questions/24056570/how-to-add-css-property-to-elements-outside-iframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!