Make links inside an iframe open in a new window

30,225

Solution 1

You will need some kind of open API to do this properly, and Eniro doesn't provide one according to this page (in Swedish).

I would recommend you to use the Google Maps API v3 instead. I've made an example on jsFiddle that looks similar to that of Eniro.

I'll gladly give you more help with this, so just ask away!

Solution 2

You can't (or it is extremely hard to ) make events inside the iframe affect the parent page. This is to prevent attacks from XSS, or cross site scripting. Having said that, if the site within the iframe is on your own domain and you want to set up some extremely tricky ajaxing and php session IDs, maybe you could make something work, but even then I'm not sure. And I don't know if this would be a security hole, maybe someone else can speak to that. It would perhaps look like:

  1. main page sets up session ID and passes that to the iframe url via a get variable
  2. the iframe takes click information and sends it to a Session variable via an ajaxing call to a script on the server.
  3. The main page then reads (how?) the session cookie and makes changes based on it's value.

All in all, you may find that it may be much simpler and more secure to acheive what you want using a different method.

Solution 3

Due this map is loaded inside an iFrame, it's not possible to run any javascript event listeners on the links, neither is it possible to change the html.

Share:
30,225
Breezer
Author by

Breezer

well what is there to say i like design and programming that's it

Updated on February 13, 2020

Comments

  • Breezer
    Breezer about 4 years

    I'm trying to display an map inside an iframe that has a needle which on mouseover shows some information about a certain company, the thing is once you click the link the page opens up inside the iframe which ruins the experience, so i was wondering is it possible to make the links inside an iframe open up in a new window instead perhaps using jquery or something similiar?

    the code i have atm is

    http://www.jsfiddle.net/rkd59/1/

    Edit: the very least capture a click within the iframe so i might resize the iframe