Click to See Complete Forum and Search --> : IP Address


Atcapollo
01-13-2003, 01:17 PM
I've been trying for days to find away of getting a viewers IP address and the inserting it into my webpage to show them. The only Javascript solution I've seen/managed is a pop up alert box and a status bar message. Any one know how I can display it as part of my webpage? Using Javascript not PHP or ASP.
Thanks in advance
Apollo

khalidali63
01-13-2003, 01:25 PM
First of all you can not get users IP address using just JavaScript.
Second if u are refferering to the URL of the page to be printed in your page thats easy.
put the code below in your web pages body section.
<div id="ip"></div>
<script>
//get the url
var url = window.location.href;
//print it in ur page
document.getElementById("ip").innerHTML = url;
</script>

Khalid

Jona
01-13-2003, 03:17 PM
You can use SSI:

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

function ipval() {
document.myform.ipaddr.value=ip;
}
window.onload=ipval
</script>

<form method="post" action="" name="myform">
<input type="text" name="ipaddr" readonly>
</form>

This will put the user's IP inside of the text box named, "ipaddr."

^_^ Happy hunting!