1

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.

marteen
  • 13
  • 2
  • You have to create an image element to the main page, and change the `src` of that element. – Teemu Jan 05 '15 at 19:35

1 Answers1

0

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

Community
  • 1
  • 1
Charlie Dalsass
  • 1,986
  • 18
  • 23