简体   繁体   中英

Invoking javascript from ifram to the whole website

does anybody know how can I expand javascript so that it targets whole website not only the page in iframe it is on. Im currently using a javascript for gallery on my website, so when you click on a picture it pops up enlarged, however since the page with javascript is in an iframe it shows only in the iframe, how can I accomplish the pop up to expand to the whole page?

Thanks in advance.

Iframes can call out to the window which embeds them using simple javascript (see window.frames on http://www.w3schools.com/jsref/prop_win_frames.asp ). However, if src of the iframe is on a different domain, then the script can only affect the iframe, due to security policy within the browser.

If you'd like to apply a work-around, there are some solutions like this: Yet Another cross-domain iframe resize Q&A

These solutions tend to break on different browsers and with updates to browsers.

Your best bet is keeping the entire iframe contents within the browser by writing the iframe code yourself (and hosting on your own domain).

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