Title: iFrame &#8211; Prevent Preloading
Last modified: June 5, 2020

---

# iFrame – Prevent Preloading

 *  Resolved [funkygorilla](https://wordpress.org/support/users/funkygorilla/)
 * (@funkygorilla)
 * [5 years, 12 months ago](https://wordpress.org/support/topic/iframe-prevent-preloading/)
 * Hi,
    Firstly, thanks for the plugin, I use it all the time and it’s so much more
   reliable than anything else. I am just looking at creating a button that loads
   another site in an iframe containing a map of locations. This other site has 
   a geolocation system to find the user. The problem is that I don’t want that 
   to load unless the user clicks to find their location. Is there any way to prevent
   the iframe from loading content until the button is clicked? I noticed that there
   is in fancybox itself, I just wasn’t sure whether you had it as a feature of 
   your plugin (or the Pro version) too. Thanks

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/iframe-prevent-preloading/#post-12951698)
 * Hi [@funkygorilla](https://wordpress.org/support/users/funkygorilla/) when you
   create a button like the code below, your link will open a popup with the other
   site map in an iframe. This map will not load before the button is clicked so
   the other site’s geolocation feature should only become active once the popup
   content has loaded. But it is not possible to influence or change this geolocation
   feature running on the remote site from your site. Being able to do such a thing
   would be a serious security issue.
 * So unless I’m misunderstanding what you wish to do, the short answer is: no, 
   that is not possible, not directly in any case.
 * `<a href="https://otherdomain.com/path/to/map" class="button fancybox-iframe"
   >Open the remote map</a>`
    (for example; the class “button” used here may not
   be present in your theme’s stylesheet and you’ll need add some style rules before
   the link will appear as a button, or use another class that is present in your
   theme’s stylesheet)
 * Your options are: either include a little warning in the text of the link button
   like “Open the remote map (activates geolocation)” or change the button link 
   to a stand-alone page on your own domain. This stand-alone page could then show
   a text like “Opening the remote map will activate geolocation. Are you sure?”
   with a link “Yes” to the remote map… Clicking that link will then load the remote
   map in the same popup iframe. And a “No” link with href=”javascript:parent.jQuery.
   fancybox.close()” which will close the popup.
 *  Thread Starter [funkygorilla](https://wordpress.org/support/users/funkygorilla/)
 * (@funkygorilla)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/iframe-prevent-preloading/#post-12951810)
 * Hi RavanH
 * Thanks for the reply. That’s what I would have expected too. I used different
   code as follows: –
 *     ```
       <a class="fancybox"  href="#fancyboxID-5">Buy In-Store</a>
       ....
       <?php	
       echo "<!-- Electrical Wholesaler Location Map -->";
       echo "<div class=\"fancybox-hidden\" style=\"display: none;\">";
       echo "<div id=\"fancyboxID-5\" class=\"hentry\" style=\"width: 460px; max-width: 100%;\">";
       ?>
       <iframe src="https://www.electrical-wholesaler.com.au/location-map-for-iframe" style="width:100%;max-width:940px;height:900px;"></iframe>
       </div></div>
       ```
   
 * This was seeming to load the iframe in the background, which was odd. I swapped
   over to your code and that is now live on [https://brau.wpmudev.host/products/fr/](https://brau.wpmudev.host/products/fr/)
   but you can see that this doesn’t open a fancybox window it just links straight
   through to the site (so the class isn’t working). Am I doing something wrong?
   
   Cheers
 *  [Rolf Allard van Hagen](https://wordpress.org/support/users/ravanh/)
 * (@ravanh)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/iframe-prevent-preloading/#post-12953317)
 * I see you have not activated the iFrame option in the FancyBox section on Settings
   > Media. You’ll need to activate that option or use the two classes “fancybox
   iframe” together (without hyphen).
 * > This was seeming to load the iframe in the background, which was odd.
 * Your source code contained the iframe itself. Even if an iframe tag is inside
   a hidden div, it will still be loaded.
 *  Thread Starter [funkygorilla](https://wordpress.org/support/users/funkygorilla/)
 * (@funkygorilla)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/iframe-prevent-preloading/#post-12974137)
 * Thanks RavanH, that worked a treat. I can move it on to the live site after a
   bit of styling now.
 * I always forget those fancybox options tucked over there! Lesson learned!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘iFrame – Prevent Preloading’ is closed to new replies.

 * ![](https://ps.w.org/easy-fancybox/assets/icon-256x256.png?rev=3188201)
 * [Firelight Lightbox](https://wordpress.org/plugins/easy-fancybox/)
 * [Support Threads](https://wordpress.org/support/plugin/easy-fancybox/)
 * [Active Topics](https://wordpress.org/support/plugin/easy-fancybox/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/easy-fancybox/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/easy-fancybox/reviews/)

## Tags

 * [iframe](https://wordpress.org/support/topic-tag/iframe/)
 * [load](https://wordpress.org/support/topic-tag/load/)
 * [preload](https://wordpress.org/support/topic-tag/preload/)

 * 4 replies
 * 2 participants
 * Last reply from: [funkygorilla](https://wordpress.org/support/users/funkygorilla/)
 * Last activity: [5 years, 11 months ago](https://wordpress.org/support/topic/iframe-prevent-preloading/#post-12974137)
 * Status: resolved