Results 1 to 3 of 3

Thread: Detecting iframe location & opening iframe location in a new tab/window

  1. #1
    Join Date
    Aug 2006
    Posts
    58
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Arrow Detecting iframe location & opening iframe location in a new tab/window

    Hi

    I'm searching for a way to open the page inside an iframe in a new tab/window.

    If let say my iframe content is initially google.com, then user cilcked (inside the iframe) the "images" link and then the iframe is directed to google.com/images.

    I want a link on my page (outside the iframe) that allows them to open google.com/images in a new tab/window. This link would follow whatever the iframe content is. So even when they browsed to some random web page from my iframe, they can open that page in a new window by using that link.

    Though i'm not going to be using this to let my users browse some random page on google in my iframe, I belive this analogy serves the purpose of explaining it :P


    I tried to google it but I can't find a relevant answer.

    Anyone can help me with this? Any answer or even pointers would be very much appreciated

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You can't detect the iframe location unless both pages are on the same domain.

    If they are, it's simple. Iframes are numbered from 0 to however many are on the page. So - say you just have one iframe:

    Code:
    <a href="#" onmouseover="this.href = window.frames[0].location.href;" target="_blank">Open Iframe Contents in a New Tab</a>
    Last edited by jscheuer1; 04-01-2012 at 04:20 AM. Reason: minor code improvement
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    k12onos (04-01-2012)

  4. #3
    Join Date
    Aug 2006
    Posts
    58
    Thanks
    14
    Thanked 0 Times in 0 Posts

    Default

    Exactly what I'm looking for! Luckily my iframe content is in the same domain. Thanks a lot!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •