By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,624 Members | 1,597 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,624 IT Pros & Developers. It's quick & easy.

detecting domain re-direction

P: n/a
Can anyone help. I'm new to Javascript so be gentle.

I have 2 registered domains which are set up to redirect to my homepages
which are on a different ISP. I have been told that it is possible to use
Javascript to detect which domain name the viewer has come from and then
switch to a different index.htm page accordingly. I have tried searching
assorted archives, but can't get anything working.
Dave
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Dave Parkinson wrote:
Can anyone help. I'm new to Javascript so be gentle.

I have 2 registered domains which are set up to redirect to my homepages
which are on a different ISP. I have been told that it is possible to use
Javascript to detect which domain name the viewer has come from and then
switch to a different index.htm page accordingly.
Only if they have scripting enabled.
I have tried searching assorted archives, but can't get anything working.

<script type="text/javascript">
if (document.referrer && document.referrer="http://www.mydomain1.com/"){
window.location = "http://www.myotherdomain.com/page1.html"
}
else{
window.location = "http://www.myotherdomain.com/page2.html"
}

Note that document.referrer returns an empty string in IE when tested
offline.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.