Solved

How to stop frame busting code from moving my users?

Posted on 2006-10-28
6
1,626 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
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…

809 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