SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
-
Sep 8, 2003, 04:16 #1
- Join Date
- Aug 2003
- Location
- England
- Posts
- 34
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
long else statementwith non javascript inbetween
Hello,
Is it possible to have a javascript function which has a lot of code inbetween { and } , a lot of which is not JavaScript. What I have is a JavaScript which will direct the user to another site if their IP matches a given address. If it doesn't match the address then the page is displayed normally.
The code was going to run something like :
if IP = 0.0.0.0 redirect.
If the IP didn't match then the page would be loaded as normal . However when the IP does match, the page sometimes shows, just for the few split seconds before it redirects.
What i'd like to do (if possible) is have something like (this is pseudocode)
<Script Language=Javascript)
get IP address
if(IP=0.0.0.0)
{
redirect
}
else
{ //start of else statment
</script>
Normal page code will be displayed eg forms.
<script language=JavaScript>
} //end of else statement
</script>
Would this scenario work?
-
Sep 8, 2003, 08:15 #2
- Join Date
- Dec 2002
- Location
- Alabama, USA
- Posts
- 2,560
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
This sounds like something that should be done server-side - conditional inclusion of html.
Do you have php or ssi support on your site?Cross-Browser.com, Home of the X Library
-
Sep 8, 2003, 13:04 #3
- Join Date
- Jul 2002
- Location
- Dallas, TX
- Posts
- 2,900
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
If you have SSI
Code:var ip = '<!--#echo var="REMOTE_ADDR"-->', url; switch( ip ) { case '192.168.1.1' : url = "page1.htm"; break; case '192.168.1.0' : url = "page2.htm"; break; default : url = "home.htm"; } top.location.replace( url );
-
Sep 9, 2003, 01:40 #4
- Join Date
- Aug 2003
- Location
- England
- Posts
- 34
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Sadly this is run through Lotus Domino, and It seems quite limited.
If it was PHP I could do it in 5 minutes!
Thanks anyway.
Bookmarks