★ wanayoo — archive 1999 http://webdeveloper.com/javascript/javascript_content_protector.htmlNouvelle recherche | Portail wanayoo
internet.com

Go to WebDeveloper Home

When you're ready to play with the big boys

Seek and you shall

or search all of internet.com
Looking for a Site Map?

Click here to sign up for a FREE Refer-it Webmaster Account

Jobs!
Find a job or the right person

The Web Developer Network
WebDeveloper.com ®
Streaming Media World
WebReference.com
Web Developer's Virtual Library
BrowserWatch
Java Boutique
Web Developer's Journal
JavaScript Source
ScriptSearch
Web Developer Forums
Web Developer News

internet.com
Internet News
Internet Stocks/VC
Internet Technology
Windows Internet Tech.
Linux/Open Source
Web Developer
ECommerce/Marketing
ISP Resources
ASP Resources
Wireless Internet
Downloads
Internet Resources
Internet Lists
International

Search internet.com
Advertising Info
Corporate Info

internet.commerce
Be a Commerce Partner
Register Domains
B2B Directory/Search
Online Banking
News to Your Desktop
Small Biz Purchasing
Offer Free Email
Hosting Services
Free Disk Space
Find a Web Host
Site Search Solutions

  Let internet.com work for you!
J A V A S C R I P T
WebDeveloper.com

The Ultimate Content Protector

By David Fiedler

Confound content and bandwidth thieves with this deceptively simple script

OK. You've been framed and you don't like it. Now what?

Although the practice is becoming less common these days, quite a number of webmasters have been surprised to find that their content pages have been "frame hijacked" by other sites.

While it's relatively simple to find when someone has actually copied your pages (just select a unique phrase, other than a copyright, and search for it on AltaVista), frame hijacking occurs when the evildoer puts your page in their frame. That makes it look as though they wrote your page (especially since their URL, not yours, is displayed). This is generally done in order to unfairly profit from your work, so you'll also usually see one of their ad banners above your content. Even worse, they're stealing your bandwidth (which you're paying for) because you're serving the pages right to their visitors!

Fortunately, it's easy to break out of unwanted frames. It only takes one line of JavaScript code (though it must be surrounded by the usual headers and footers) in the <BODY> of your page:

<script language="JavaScript">
<!-- Begin
if (window != top) top.location.href = /old?u=http%3A%2F%2Fwebdeveloper.com%2Fjavascript%2Flocation.href&y=1999
// End -->
</SCRIPT>

You don't even have to understand any JavaScript to cut and paste that one, but basically it tests to see whether your page is the topmost window frame of the browser, and if not, forces itself to jump out of the enclosing frame.

But wait, there's more.

Let's say that your content is already framed, because you designed it that way. It's in your own frames, in fact. The bad guy comes along, creates his own frame for your content on his own site, and so on. But you can't use the above script, because it will break your page out of all frames, including your own. What to do?

This happened to me on one of my sites, so I thought I'd cleverly toss off a little JavaScript program to break out of frames unless they were on my site.

Ha.

The first thing I tried was checking the address string of the page if it was in frames, to make sure it matched my domain and enclosing frame's name.

The next thing the "bad guy" did was set up a subdirectory with the same name as my domain, and used the name of my enclosing frame. This, of course, fooled my script.

So of course I rolled up my sleeves and prepared to do battle.

[ Click here to move to the next part of the article ]

Fast Jump to Anywhere on WebDeveloper.com®:

Let internet.com work for you!



Copyright © 1999-2000 internet.com Corp.
All Rights Reserved. Legal Notices.
Contact the WebDeveloper.com® staff

Last modified: Thu Jun 15 06:12:48 EDT 2000

http://www.internet.com

 

Refresh Daily
Join Editor-in-Chief David Fiedler The Editor With No Time and find truth, justice, and a clue or two.


Browse by Category
[ Site Map ]

ActiveX / VBscript
Animated GIF Archive
Browsers
CGI / Perl
Database Connectivity
Design / Graphics
E-Commerce
HTML-Advanced: DHTML, CSS
HTML / Site Authoring Tools
Intranet/Groupware
Java
JavaScript
Multimedia: Audio / Video / Streaming Technologies
Opinions
Refresh Daily: Editorial Column
Security
Servers & Server Tools
Site Design / Graphics
Site Management / Marketing / Log File Analysis
Tutorials
VRML / 3D
XML