Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1658
  • Last Modified:

How to stop frame busting code from moving my users?

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
JimHubbard
Asked:
JimHubbard
1 Solution
 
riaancorneliusCommented:
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
 
JimHubbardAuthor Commented:
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
 
jabaswavikaCommented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
JimHubbardAuthor Commented:
I got it.......thx anyway.

Since you were the only 1 that answered - here's 500 pts for your 2 cents!
0
 
JimHubbardAuthor Commented:
I am using IE7.  But, I found the problem......
0
 
web2upgradeCommented:
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now