1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Break Out of IFRAME when URL changes

Discussion in 'General Programming Chat' started by frenchboy, Nov 1, 2008.

  1. frenchboy

    frenchboy Jr. VIP Jr. VIP Premium Member

    Joined:
    Aug 19, 2008
    Messages:
    643
    Likes Received:
    1,276
    I'm framing in a portion of anotherwebsite.com on mywebsite.com/page (urls are just for example), which looks just fine and gives me the desired result I'm looking for. However, when someone clicks on a link inside the IFRAME the content inside the IFRAME will change to something like anotherwebsite.com/contactus, but I will not want these other pages to be embedded inside the IFRAME. I would like to have the user broken out of the IFRAME somehow into a pop up window with the full URL or just have the browser load the new URL. Is there anyway to detect this URL change and break the user out of the IFRAME? The website embedded in the IFRAME is not mine, so I don't have control over the content or code behind the site. Thanks.
     
  2. ernesthemingway

    ernesthemingway Regular Member

    Joined:
    Oct 5, 2008
    Messages:
    200
    Likes Received:
    2,990
    Occupation:
    Comp Engineer
    Location:
    Planet Mars
    Can you make your post a bit clear please, I am sort of confused. I know you could control few of iframe features...

    but are you iframing it with zeros or visitors can see it?
     
  3. BozoClown

    BozoClown Junior Member

    Joined:
    Jan 4, 2009
    Messages:
    150
    Likes Received:
    106
    Simple answer and first thought: No you cannot.

    Second thought answer:
    It may be possible. If I am thinking right, you could do this with some simple JavaScript to constantly check the DOM for changes of the <iframe> src attribute. If it is not the original value then you issue the breakout code. If it is the original value you do nothing.

    Set this function to run every second or half second. That should give you an acceptable real time.
     
    • Thanks Thanks x 2
  4. frenchboy

    frenchboy Jr. VIP Jr. VIP Premium Member

    Joined:
    Aug 19, 2008
    Messages:
    643
    Likes Received:
    1,276
    Visitor can see a piece of the page, but not the whole thing. In that piece that they see, there is a link, once they click the link, I would like the iframed page to break out of its frame and be seen completely.

    By the way, if someone would like to code something that does this I'd gladly pay for it.
     
  5. hogatoga

    hogatoga BANNED BANNED

    Joined:
    Sep 20, 2008
    Messages:
    151
    Likes Received:
    36
    How do you stop the iframe breaker, any suggestions anyone?
     
  6. r0cker

    r0cker Newbie

    Joined:
    May 23, 2008
    Messages:
    29
    Likes Received:
    213
    Location:
    Walpurgisnacht
    use some javascript. if i remember right "top.location=url" should do the job.
    this works like a redirect then, so any iframe should break here.