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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting IP address and then redirecting them...

Status
Not open for further replies.

WildWest

Programmer
Apr 2, 2002
111
0
0
US
I need to figure out how to detect a users IP address and depending on their IP address redirect them to site A or site B. I'm unable to use server-side scripting languages like ASP, PHP, and ColdFusion. I need to use JavaScript.

Any help would be greatly appreciated. Thanks!!!
 
AFAIK, you cannot do that client-side without a little configuration in your server (SSI, for example)

Cheers,
Dian
 
Again AFAIK, that script needs SSI in the server.

Anyway, if you rely on it, redirecting is the easy part

Code:
if (ip == "Whatever IP"){ 
var nUrl="Whatever URL to redirect"; 
window.location.href=nUrl;
}

Cheers,
Dian
 
even so -

many people (depending on the browser they use) can set up their browser so that it won't send information such as IP addresses.

In my opinion, find another way to do what you need to do. Maybe ask them where they need to go, and then store a cookie with that page.

*cLFlaVA
----------------------------
[tt]your mom goes to college[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top