简体   繁体   中英

How to change style of iframe content cross-domain?

I want to make background color black and text color white for the content inside iframe from its default of normal white background and black text. The iframe src attribute points to different domain to which I have no access or cannot place any file or stylesheets in that domain. So given these conditions is it possible to make just these style changes in the iframe content and if so then how?

The only possibility would be to load the iframe content through a proxy of yours and modify the HTML content. You can not access iframes from another domain via JavaScript.

It isn't possible. The whole point of the Same Origin Policy is that you can't access or manipulate content from another domain.

This one's been here a while, but hopefully this will help someone....

The closest I can see is using a filter on the iframe

Xray: makes it black and white then inverts it.

 <iframe style="filter:xray" src=".....

Invert: inverts all the colors rather than just swapping black & white.

 <iframe style="filter:invert" src=".....

Both only work in IE. I thought these only worked on images till a few minutes ago...

eg. http://www.ssi-developer.net/css/visual-filters.shtml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM