PDA

View Full Version : javascript redirection


universe
21-04-2002, 17:15/05:15PM
I have a javascript redirection script (resolution redirect) in my index.html and i'm worried if i'm not going to be banned from SE for that. Script looks like this...
<title>MGM |TECHNOLOGY|</title>
var url800x600 = "low.html";
var url1024x768 = "high.html";
if ((screen.width == 800) && (screen.height == 600))
window.location=url800x600;
else if ((screen.width == 1024) && (screen.height == 768))
window.location=url1024x768;
else window.location=url1024x768;

I also use the "frames escape" script that looks like this:
if (top == self) self.location.href = "index.html";

please help

Alan Perkins
21-04-2002, 18:22/06:22PM
The JavaScript resolution redirection is fine. But if someone doesn't have JS, they are not redirected anywhere. What do they see?

The frames redirect is also OK. There is an alternative solution on our site that doesn't involve a redirect, so searchers see what they are looking for. We call it the Self Referencing Frameset (http://www.searchmechanics.com/learn/srf/).

universe
21-04-2002, 18:39/06:39PM
So which javascipt redirects are forbidden by SE?
Self Referencing Frameset is great i will be using it for sure

Alan Perkins
21-04-2002, 18:46/06:46PM
Originally posted by headh
So which javascipt redirects are forbidden by SE?
The ones that redirect from spam pages. That's why I asked what your visitors without JavaScript would see. It's important that they see content designed for humans.

universe
21-04-2002, 18:50/06:50PM
so what should i do to make resolution redirect se friendly?

Alan Perkins
21-04-2002, 18:55/06:55PM
It should be OK as is. But let me give you an example. Let's suppose that the page the script was on was set up for 1024x768 - no need to redirect anywhere. Your script would reduce to

var url800x600 = "low.html";
if ((screen.width == 800) && (screen.height == 600))
window.location=url800x600;

And people without JavaScript (and SE spiders) would see some useful content.

universe
21-04-2002, 19:00/07:00PM
right, thats very useful advice
thanks a lot

Matt B
23-04-2002, 15:14/03:14PM
Be careful when implementing javascript to load the frameset. Some scripts disable the back button (because it is going back to the initial frame then directs the frameset to load again.) SE's do not like that.

There are some scripts out there that can avoid that problem.

Black_Knight
06-07-2002, 23:56/11:56PM
The robots for both Google and Altavista (at least) both recognise the significance of the JavaScript "location." as a redirect. Google once dropped an entire site for having exactly the kind of redirect for frames that we are discussing here.

Use external javascript files.

Secondly, using the location.href method of redirection will always break the back button. That's because going back would take them to the javascript that launches them forwards again immediately. Bad move.

Instead, always use the location.replace(); method instead, which replaces the current URL in the browser history, meaning the back button goes straight to the page before the one with the script.