Forum Moderators: open

Message Too Old, No Replies

JScript on page

Stopping visitors viewing frame pages out of frames - Good or Bad?

         

Efexx

3:59 pm on Jul 21, 2002 (gmt 0)

10+ Year Member



I have the following code on some of my pages:

<SCRIPT LANGUAGE="JavaScript">
<!--
if (top == self) self.location.href = "index.htm";
// -->
</SCRIPT>

This was too stop vistors visiting these pages which on their own did not mean why much when viewed out of frames. Do the search engines see this and penalize it in any way?

Many kind regards,
Efex

tedster

4:56 pm on Jul 21, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



We've been doing something like this on one client site, with no apparent problem - but your exact code does look like a near-universal redirect (which may catch some flak at any time!). Also, if you are using it on many pages, it sends them all to the same index.html, which is not the best solution for your visitors who wanted a specific page.

So, with this particular site, we did two things:

1. Moved the javascript to an external .js file
2. Used a friendlier script that loads the exact page requested into the frameset. You can see the javascript for this technique at message #21 on the Generic Javascript Thread [webmasterworld.com] over in the Browsers and HTML forum.

piskie

10:43 pm on Jul 21, 2002 (gmt 0)

10+ Year Member



I used this after Tedster answered a similar post from me. The only difference is that I put my js files into a folder that excluded all spiders. This works fine and I have had no S/E problems.

Sorry Efexx I am forgetting to welcome you to WebmasterWorld.

Efexx

12:26 am on Jul 22, 2002 (gmt 0)

10+ Year Member



Many thanks for you replies, I wrote tedster a sticky on the subject. I do have one more question tho:

I have never used seperate .js files; so could you possibly explain exactly how to do this, including the call routine required. I know how to put them into an unspiderable folder tho :)

Many kind regards,
Marc

piskie

1:03 am on Jul 22, 2002 (gmt 0)

10+ Year Member



The js code is probably best proved by putting direct into the head of the document and when it works, remove the script opening and closing tags then paste the lines of code in your text editor thus creating your js file.

The js file is best created using a basic text editor like notepad.
save it as a text file "xyz.js"

To call up the file, insert into the head of the HTML document:-

<script language="javascript" type="text/javascript" src="noindex/xyz.js"></script>

Good luck.