Forum Moderators: open

Message Too Old, No Replies

Change links within an iframe

Change links within an iframe?

         

madmatt69

7:15 pm on Apr 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Heya,

So I've got an iframe in a page that pulls a url from an affiliate company i work with. Unfortunately that means I can't change their code, as I don't have access to. I can just open their iframe.

The links in the iframe keep opening new windows when clicked on, and I'd like to keep them in the iframe.

Is there a javascript solution for this? I'm thinking do something with the iframe like onLoad, grab the href's of the links in the iframe and add some code that will say to open links in the current window of the iframe.

I can't seem to find anything in google about this, but I think it's possible. If anyone can point me in the right direction, it'd be greatly appreciated!

Dabrowski

8:26 pm on Apr 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nope.

If the IFRAME is on a different domain you can't access anything in it with JS. The only way would be to add some code into their site so you could sent commands via the URL, but you can't.

If the IFRAME was on the same domain you could use an onLoad on the IFRAME and search the IFRAME's DOM to change the links.

Sorry.

madmatt69

8:56 pm on Apr 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmm.

I was thinking if I make an iframe which contains their iframe, and reference that. But it probably still comes down to the same problem.

Dabrowski

11:32 pm on Apr 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yep. Just one level down.

You used to be able to do it years ago but it was taken out as a security risk. Think about it, you could IFRAME anybody's site and tweak it to do anything you wanted it to, causing problems for the host site.

Same reason you can't access history URL's either.