Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

browser independant redirect base on just the domain

Status
Not open for further replies.

How browser independant?

You need it to work for which browsers?
 
Currently -

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
fp=0;
if (navigator.appName.indexOf(&quot;Netscape&quot;) > -1){
fp=0
}
if (navigator.appName.indexOf(&quot;Microsoft&quot;) > -1){
fp=1;
}
if (fp == 1) {
<!---if IE--->
[IE STYLE REDIRECT]
}
else{
document.write('')
[OTHER STYLE REDIRECT]
}
</script>
 

At the start, you said you wanted to redirect depending on the domain, but your code is using the browser name.

Which is it?
 
whoops - old bit of code - I need to use the domain - how do you do that---
 

You'll need to be a bit clearer, mate. You want to test on the referring domain, the current URL, or what?
 
the current url

I usually use cf to do a redirect based on the domain.

I suppose i want to set a var as the domain, then do a swich with some actions based on that var...
 

If you get the current URL like this;
Code:
current_url = document.location.href;
... and test like this:
Code:
if( current_url.indexOf( &quot;your_test&quot; ) != -1 )
.. and so on.

Or, like you said, switch-case.

HTH.
 
so will this working in any browser, I thought there was a different location syntax for diff browsers...

current_url = document.location.href;

switch (current_url) {
case 'United States':
window.location='my url';
break;
default:
window.location='my url';
}
 
case whould be the url, not 'united states'
 

I think I finally see what it is that you want: a different redirect depending on whether it's &quot;.com&quot;, &quot;.co.uk&quot;, &quot;.net&quot;, or dot whatever.

Correct?

If so, why are you using Javascript to do it?

------------------------------------

Quote: &quot;I thought there was a different location syntax for diff browsers&quot;

Search the web, fella. I'm not a reference.

 
its depends on the whole domain. In this particular instance - I cannot use iis, php or coldfusion. There are 5 domains parked - and I need to redirect to a different page - including the same page, but change the domain.

eg: they type in bob.com > bob.com

they type in bill.com > the same page as bob.com

they type in milly.com > redirect to bob.com (even though its parked and could work as milly.com).

M@)
 
Why not just put something like this on each page?

Code:
<script type=&quot;text/javascript&quot;>

document.location.replace( &quot;[URL unfurl="true"]www.bob.com&quot;[/URL] );

</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top