redirected web pages

J

John Seeliger

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
 
W

Whitecrest

I tried asking this in comp.lang.javascript, but didn't really get the
answer I am looking for....

Hmmmm..... not the answer you were 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.

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.
 
M

Mitja

Whitecrest said:
Hmmmm..... not the answer you were looking for....


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

<snip>

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

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.
 
N

nice.guy.nige

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


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

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. (e-mail address removed). Take the dog out!
http://www.nigenet.org.uk | Boycott E$$O!! http://www.stopesso.com
In the land of the blind, the one-eyed man is very, very busy!
 
M

Michael Wilcox

John said:
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.

There's better ways of doing this than JS. If you having any sort of
server side processing (SSI, PHP, etc.), then you should be doing this
as per <http://www.w3.org/QA/Tips/reback>.

There's no point to having a message telling people, since if they
bookmark the page, they'll do it to the good URL.

BTW, Google may not like it when you do this.
<script language = javascript type = "text/javascript">

The language attribute is deprecated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top