Frame Blocking

This demo explores how to employ frame-blocking to prevent a Web page from appearing within a frame. Click the link in the left frame to view the file default.htm. The page will appear within the right frame. However, if you add the following JavaScript commands to default.htm and run them when the page is loaded

if (top.location.href != self.location.href) { 
top.location.href = self.location.href;
}

the browser will compare the URL of the topmost window to the URL of default.htm. If different, JavaScript will change the location of the topmost window to the location of the current window. As a result, default.htm will jump to the top of the frame hierachy, replacing the entire frameset.