Page Protection Using Frames & JavaScript


Many WebTV users have a concern with people not going to their home or portal page and instead going directly to another page in their set, thus missing the site counter. What should also be of concern is that search engine spiders may also pick one or more pages and miss the portal page completely. Disturbing to some as well is people looking at their source code which, while it cannot be prevented can be made more difficult if a frames construct was used.

A frames construct consists of a page which sets up how the frames page is formatted, and thereafter has many pages which go with each part of the format. A frames page is therefore not just one page but a whole collection of pages. It is desirable in this case to build in a code so that search engines will recognize only one page, the frameset page, and not some or all of the pages that make it up. Such codes are also useful in preventing people from "lifting" only certain pages from the set.

Since a collection of pages is involved, a code must be placed in the <head> section for every page in the collection. One code insures that the parent or self beginning page, the top most of the set, has child pages that belong together and are not separate. All subsequent pages have a code identifying them as "children" of the "parent" page. These codes are entered in the <head> section of a page.

Frameset Page:

<script>
if(top.location!=self.location){
top.location=self.location;}
</script>

All Other Pages:

< script>
if(top.location==self.location){
top.location.href="otherpage.html";}
</script>



For a frames page that has a navigation sidebar on the left and has other pages loaded to the right a page protection code would be entered for the frameset page, for the left sidebar page, and for all other pages that are to be loaded to the right.

Frame-Set Page:

<head>
<script>
if(top.location != self.location){
top.location=self.location;}
</script>
;
</head>
<body bgcolor=? text=??>
<frameset cols="25%,75%">
<frame src="left.html" name="left">
<frame src="right0.html" name="right">
</frameset>
</body>

left.html Page:

<head>
<script>
if(top.location==self.location){
top.location.href="left.html"}
</script>

</head>
<body bgcolor=? text=??>
Links for right pages.
</body>

right0.html Page

<head>
<script>if(top.location==self.location){
top.location.href="right0.html"}
</script>

</head>
<body bgcolor=? text=??>
Content of right0.html page.
</body>




The codes involved are simple enough, even though they entail JavaScript which is aversive to some. All that need be done, though, is to c/c/p them in their own pages with appropriate URLs. Frames may be equally off-putting to many, but the codes given are for a sidebar with a changing instead of a scrolling main page. This may be sufficiently different, along with the security feature, to encourage some to try them. Indeed, the main page can even be made to scroll up and down as usual.