www.webdeveloper.com
Results 1 to 3 of 3

Thread: 🔴► Frame Break Out, needs little modification, please HELP

Hybrid View

  1. #1
    Join Date
    Feb 2012
    Posts
    23

    🔴► Frame Break Out, needs little modification, please HELP

    Hey guys I use this tiny javascript to break out of frames (works great), but sometimes this causes my website to keep on reloading over and over, is there any way to modify this code so that it only does it once? Or only once per visitor?

    Code:
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    setTimeout ("changePage()", 1000);
    function changePage() {
    if (self.parent.frames.length != 0)
    self.parent.location="http://MY-SITE.com";
    }
    // -->
    </SCRIPT>

  2. #2
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    There's no need for that code to be written as a function, much less for it to be run from a timeout.
    That code will error if your page is framed by a different domain.

    Code:
    <script type='text/javascript'>
    
    try
    {
       if( top.document.domain !== self.document.domain )
       ; // Error if true
    
       if( self !== top )
         top.location.href = self.location.href;
    }
    catch( e ){ top.location.href = self.location.href; }
    
    </script>

  3. #3
    Join Date
    Feb 2012
    Posts
    23
    I really don't know anything about javascript. And you're awesome, that works great :-) Thank you very much.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles