We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
  • Pages:
  • 1
  • 2
Javascript?
Topic Started: Jan 28 2005, 12:51 AM (875 Views)
Stefan
Member Avatar
Mew?
[ *  *  *  *  *  *  * ]
kingy
January 29, 2005 01:07 PM
Code:
 

<script type='text/javascript'>

ip = '<!--#echo var="REMOTE_ADDR"-->'
allowed = 202.90.38.2

if (ip = allowed)
{
alert('You have the right IP')
} else {
alert('You don't have the right ip')
}



ok that was really quick, and basically shows you how this would work (i think). you could chnage allowed to whatever IP you want to see whatever the content is. For the benifit of this i just made it display alert messages

Code:
 
allowed = 202.90.38.2

The value should be enclosed by quotes.
Code:
 
allowed = '202.90.38.2'



Code:
 
if (ip = allowed)

That would assign the value in allowed to the ip variable. It would yield true if the allowed variable is neither 0, an empty string "", nor null.
To test for equality, use the == operator.
Like this:
Code:
 
if (ip == allowed)
Offline Profile Quote Post Goto Top
 
kingy
1 in 10 people understands binary, the other 1 doesn't
[ *  *  *  *  *  * ]
whoops...i was doing that really quite, meant to use ==

as for the quotes, thanks, i didn't know that

Code:
 

<script type='text/javascript'>

ip = '<!--#echo var="REMOTE_ADDR"-->'
allowed = "202.90.38.2"

if (ip == allowed)
{
alert('You have the right IP')
} else {
alert('You don't have the right ip')
}
</script>


thats the proper version
Offline Profile Quote Post Goto Top
 
Renee S
Renée S
[ * ]
kingy
February 1, 2005 09:59 AM
whoops...i was doing that really quite, meant to use ==

as for the quotes, thanks, i didn't know that

Code:
 

<script type='text/javascript'>

ip = '<!--#echo var="REMOTE_ADDR"-->'
allowed = "202.90.38.2"

if (ip == allowed)
{
alert('You have the right IP')
} else {
alert('You don't have the right ip')
}
</script>


thats the proper version

Code:
 
alert('You don't have the right ip')

should be.
Code:
 
alert('You don\'t have the right ip')
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
Stefan and Renee S win the chocolate bunneh. :D
Offline Profile Quote Post Goto Top
 
kingy
1 in 10 people understands binary, the other 1 doesn't
[ *  *  *  *  *  * ]
lol, damn i was close that time
Offline Profile Quote Post Goto Top
 
Das
Member Avatar
Smells of rich mahogany
[ *  *  *  *  *  *  * ]
You get half a chocolate bunneh
Offline Profile Quote Post Goto Top
 
kingy
1 in 10 people understands binary, the other 1 doesn't
[ *  *  *  *  *  * ]
lol, w00t
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Technology Chat · Next Topic »
Add Reply
  • Pages:
  • 1
  • 2