Solved

How to stop frame busting code from moving my users?

Posted on 2006-10-28
6
1,628 Views
Last Modified: 2009-07-29
I have a frameset with a navigation frame consisting of user-posted links and a content frame to show the links in.

Sometimes a user will post a link to a site or page that has frame busting code in it like that at http://grizzlyweb.com/webmaster/javascripts/examples/framesbuster.htm for example.  I don't want content on my pages that authors don;t want posted there, but I also don't want the authors of the frame busting code to take my attention-challenged visitors away from my site either.

I obviously can't read the source of the framed pages from my page (some domain saftey rules or something), and I don't want to set up a server to do something I think I should be able to do in client side code.

I have been looking into using the onunload and onbeforeunload events to ask the users of my webpage if they want to continue on to a page that is using frame busting code to break out of my framed links page OR would they like to stay on my site and report the link.  (Then I can remove the offending link.)

But, I have been at a loss as to how to use onunload or onbeforeunload to stop code like that at http://grizzlyweb.com/webmaster/javascripts/examples/framesbuster.htm from whisking my users away to their site.

Here is my test  code....

.............................................
FRAMESET.html...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<SCRIPT>
function closeIt()
  {
    event.returnValue = "Any string value here forces a dialog box to \
                        appear before closing the window.";
  }
</SCRIPT>
</head>

<frameset onBeforeUnload="closeIt()" rows="80,*" frameborder="no" border="0" framespacing="0">
  <frame src="UntitledFrame-2.html" name="topFrame" scrolling="No" noresize="noresize" id="topFrame" title="topFrame" />
  <frame src="Untitled-1.html" name="mainFrame" id="mainFrame" title="mainFrame" />
</frameset>
<noframes>
<body>
</body>
</noframes></html>


-----------------------------------------------

UntitledFrame-2.html...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<SCRIPT>function closeIt()
  {
    event.returnValue = "Any string value here forces a dialog box to \
                        appear before closing the window.";
  }
</SCRIPT>
</head>


<body onbeforeunload="closeIt()">
<p><a href="http://www.cnn.com" target="mainFrame">CNN</a>
            <a href="http://www.drudgereport.com" target="mainFrame">Drudge</a>
            <a href="http://grizzlyweb.com/webmaster/javascripts/examples/framesbuster.htm" target="mainFrame">Grizzly</a>
            <a href="http://www.codingforums.com/forumdisplay.php?f=2" target="mainFrame">cs</a></p>
<p>&nbsp; </p>
</body>
</html>

-----------------------------------------------

Untitled-1.html...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<SCRIPT>
function closeIt()
  {
    event.returnValue = "Any string value here forces a dialog box to \
                        appear before closing the window.";
  }
</SCRIPT>
</head>

<body onbeforeunload="closeIt()">
</body>
</html>

......................................................

So......what am I missing?  Why does the Grizzly link take away my ciustomers without a choice being displayed to them?
0
Comment
Question by:JimHubbard
6 Comments
 
LVL 9

Accepted Solution

by:
riaancornelius earned 500 total points
ID: 17827968
Quite frankly, you have to ask whether you want to assume that your users are that dumb. There is nothing I hate more than a website trying to force me not to leave, and I'm not the only one.
If a user wants to go back to your page, assume that they can figure out how to hit the back button...
just my 2c worth (adjusted for inflation of course...)
0
 

Author Comment

by:JimHubbard
ID: 17828003
I do volunteer work at Hi Hope Service Center.  And, these users are mentally challenged (not necc retarded) adults who need some help developing web skills.  They are not "dumb" - they are just not as capable as some people are at not getting distracted - especially on the web.

My aim is not to force users not to leave, but to let the users know they are leaving the site.  If they still wish to do so, they should be able to continue.  But, it would be to their advantage to stay and complete their web lessons.

I just want my users to have the choice.  How do I give them that choice, considering the use of "windwow-target" and ".location" javascripts that whisk them away without giving me the opportunity to make sure that is what they want to do?

Here's your change....2c.

0
 
LVL 3

Expert Comment

by:jabaswavika
ID: 17828030
I tried your example on IE6 sp2 and it seems to work
I click on the grizly link and I get the alert box.

Let me know your browser/OS
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:JimHubbard
ID: 17828045
I got it.......thx anyway.

Since you were the only 1 that answered - here's 500 pts for your 2 cents!
0
 

Author Comment

by:JimHubbard
ID: 17828047
I am using IE7.  But, I found the problem......
0
 

Expert Comment

by:web2upgrade
ID: 23058838
Hi Jim,

I have a similar issue.  I have a site where I allow people (from frames) to chat and comment on other sites in my frameset and I have yet to find a solution for the breakout code.

Can you please tell me how you did it???

It would be GREATLY appreciated!

Thanks,
Robert
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question