# redirected web pages

#### Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

•  Subject
• Author
• Posted on
I tried asking this in comp.lang.javascript, but didn't really get the
answer I am looking for.  They wanted me to do it a different way with a
meta refresh, which I might end up doing but anyone here know if this would
work.

I have several domains including johntexas.com.  I have four of them
redirected to johnstexas.com, which is hosted.  The redirections put them in
a frame and I found the code to pop them out, but I want to put a message
into the code only when a redirection occurs.

I used:

<script language = javascript type = "text/javascript">
<!-- hide from older browsers

if (top.location != self.location) {
document.write('You have entered johntexas.com, jonstexas.com, jontexas.com
or johnseeliger.name and been redirected to johnstexas.com.  This is not an
error.');
top.location = self.location;
}

Now when you click on www.johntexas.com , you get redirected to
www.johnstexas.com , but it doesn't print my message.  Am I doing it wrong?

Thanks,
-John

## Re: redirected web pages

John Seeliger wrote:

Yes it does. It just redirects too fast for you to read it. Add a little
time delay between the message and the redirect.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?page=132

## Re: redirected web pages

Hmmmm.....  not the answer you were looking for....

Change the host.  Not all hosts put it in a frame.

Your solution will not work on everyone's machine because some people
have javascript turned off.

Second, you are writing to the document,then immediately redirecting.
This is akin to writing on one page of a book then turn the page.  Of
course you cannot read what you wrote, you turned the page.

--
Whitecrest Entertainment
www.whitecrestent.com

## Re: redirected web pages

It's OK to use JS as long as you provide a fallback mechanism. For example,
display the default page, then immediately redirect the user or rewrite the
page with your special message, if needed. If JS works, user doesn't have
the time to see the default page. If it doesn't, he just avoids the
redirection page.

## Re: redirected web pages

feverishly typed:

It could also be an available option in his redirection. For instance, the
registrar I use (http://www.123-reg.co.uk ) allows you to redirect a domain
name to a uri, either framed (to keep the domain in the address bar) or
unframed (to show the new uri in the address bar). For a site I recently
worked on (http://www.visitcaves.com ) they wanted .com, .org, .co.uk and
.org.uk tlds, so I registered all 4 addresses, set the nameservers for .com
(the 'prime' address that they wanted) and set up unframed redirects to the
.com address for all the others. This way, if anyone types in any of the
other addresses, they get taken straight to the .com address. This won't
show the message that the OP was after, but at the end of the day is that
really necessary? The visitor might not even notice, and if they do, this
kind of redirection is fairly common on the web.

Sorry if this sounds like I'm preaching to the converted, Whitecrest, but
most of it is more for the benefit of the OP than you. :-)

Cheers,
Nige

--
Nigel Moss.

Email address is not valid. nigel@nigenetDOG.org.uk. Take the dog out!
http://www.nigenet.org.uk | Boycott EO!! http://www.stopesso.com
In the land of the blind, the one-eyed man is very, very busy!