SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jun 2003
    Location
    South Carolina
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Break out of someone's frames into a new window?

    Hi all,

    I have a client who's website is being trapped inside of someone else's frames. Using a "framebuster" script would normally be fine except that the person linking to my client's site is upset that his site is being replaced in the browser window by my client's site without a way to get back to his website (which is framed). It is also annoying because when the visitor clicks the browser Back button, it just redirects to my client's site again.

    Our original idea was to simply tell the person linking to my client's website to code his link to open my client's website in a new window. However, he apparently does not have the ability to do this since his website is maintained via an Admin Panel. He can put links on his page but cannot control how they open.

    What I would like to do is put a script on my client's website which breaks out of this guy's frame, but instead of opening in the same browser window, opens my client's site in a new window. Is this possible?

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Put the following in the HEAD element. But I'm not sure if this is exactly what you need. This will open your page in a window named 'myWin' for any site that tries to enclose it with frames.
    Code:
    <script type='text/javascript'>
    if (top.location != document.location) {
      window.open(document.location, 'myWin');
    }
    </script>

  3. #3
    SitePoint Member
    Join Date
    Jun 2003
    Location
    South Carolina
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Mike. That worked great!

  4. #4
    SitePoint Enthusiast kgish's Avatar
    Join Date
    Dec 2001
    Location
    Gouda, The Netherlands
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's another variation on the theme which does the same thing but in my opinion a bit more elegantly:

    Code:
    if (top.frames.length!=0) top.location=self.document.location;
    Kiffin
    Your average future-famous kind of guy...

  5. #5
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Kiffin!


  6. #6
    SitePoint Enthusiast kgish's Avatar
    Join Date
    Dec 2001
    Location
    Gouda, The Netherlands
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MikeFoster
    Hi Kiffin!

    [img]images/smilies/smile.gif[/img]
    Hi Mike, long time no see!

    Whatever happened to the CBE disussion forum?
    Kiffin
    Your average future-famous kind of guy...


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
  •