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

Displaying a different website based on source internet address ?

P: n/a
Hello,

Based on the source internet address a different version of the website
should be presented/served to the user/browser.

For example in pseudo code:

if SourceAddress = '143.3.5.1' then
begin
ShowBlueWebsite; // Load/Show BlueIndex.htm
end else
if SourceAddress = '124.5.15.7' then
begin
ShowRedWebsite; // LoadShow RedIndex.htm
end;

Is this possible with java script ? is there any source code available
to do this trick ?

Bye,
Skybuck.

Aug 29 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
document.location.host contains the host portion of the URL (in your
case an IP).

You could use that in a script on your main index page to send a
redirect.

The problem is, what happens if someone without javascript enabled
shows up on your site?

I would recommend having one or the other be default (let's say
index.html is defult and it is the blue page). Then you could put your
script on that blue page. Check the host and if the host is 124.5.15.7
we'll show redindex.html page instead.

So a simple example (this goes in the head section of index.html which
refers to blue page) would be:

<script type="text/javascript">
if (document.location.host == "124.5.15.7") {
document.location = "/redindex.html";
}
</script>

Aug 29 '06 #2

P: n/a
"Skybuck" <sk*********@hotmail.comwrote in news:1156872351.238223.87460
@m79g2000cwm.googlegroups.com:
Based on the source internet address a different version of the website
should be presented/served to the user/browser.
What do you mean by "the source internet address"? Perhaps you mean the
"referer" or "referring page" (the URL of the previous webpage from which a
link was followed).
Aug 29 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.