SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Aug 2009
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Controlling links in an iFrame

    I'm embedding an external website that I do not have control over into my site using an iFrame. My problem is that some of the links inside the iFrame open the iFramed site in the same tab, which takes the user away from my website.

    What I'm trying to do is influence the links inside the iFrame so they behave similar to target="_blank", so they open in a new tab, leaving my site intact in the original tab.

    So far in my research its looking like it's impossible to influence the links inside an iFrame in this fashion without having control of the actual iFrame content. If it is in fact not possible, is there another solution for embedding another site within mine that allows this control, that's not an iFrame?

    Thanks so much for the help!

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2007
    Location
    North Yorkshire, UK
    Posts
    483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It horrible to think that a person wants to move away from your website but it, as a user, always annoys me when a link opens a new tab or window. If I wanted that to happen I would hold the control or shift key down.

  3. #3
    SitePoint Member
    Join Date
    Aug 2009
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see what you're saying that links that open new tabs are annoying, and the only reason that's what I'd like to have happen is so my site doesn't disappear. Ideally, I'd like the link to open inside the iFrame. So if the user clicks a link inside the iframe window, the link is displayed inside the context of the iFrame, so my site can continue to wrap the content. Is this possible?

  4. #4
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,702
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    What you're asking isn't possible. And besides, why would you place another person's website in an IFRAME?
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  5. #5
    SitePoint Member
    Join Date
    Aug 2009
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There are legitimate reasons to include someone else's content in your website without stealing/copying their content. If such a thing isn't possible with an iFrame, is there another way to embed a site that could work? Perhaps jQuery?

  6. #6
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,702
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    You can use the OBJECT tag, but it's not supported by Internet Explorer.
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  7. #7
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,296
    Mentioned
    460 Post(s)
    Tagged
    8 Thread(s)
    A recent thread discussed using an <object> instead of an iFrame, with some other interesting alternative aslo mentioned:

    http://www.sitepoint.com/forums/show...83#post4418883

    and felgall proposed a solution for IE6:
    http://www.sitepoint.com/forums/show...3&postcount=12

    Felgall's site gives more info:
    http://www.felgall.com/noiframe.htm

  8. #8
    SitePoint Enthusiast
    Join Date
    Oct 2009
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,

    I have done this with an e-learning website that wanted to let students view other web pages without any of the links working.

    All that happened was the page source was read, amended and outputed to the screen.

    You could do something similar by inserting a target attribute into every <a> tag. Of course it wouldn't trap javascript but it would be a start.

    I hope that helps.

    Regards,


    David
    David McLeary
    Emerging Innovations
    Website Development, Training and Consultancy


Tags for this Thread

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
  •