javascript怎么获取本机与外网ip地址

发布时间:2020-06-01编辑:脚本学堂
javascript如何获取本地ip地址,以及怎么取得外网ip地址,这里分享一段代码,借助外部php程序取得本机或外网的ip地址信息。

例子:
 

复制代码 代码示例:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> 
<html><head>
<title>js获取本机与外网IP地址 - www.osxue.com</title> 
<script language="javascript"> 
VIH_BackColor = "palegreen"; 
VIH_ForeColor = "navy"; 
VIH_FontPix = "16"; 
VIH_DisplayFormat = "You are visiting from:<br>IP Address: %%IP%%<br>Host: %%HOST%%"; 
VIH_DisplayOnPage = "yes"; 
</script> 
<script language="JavaScript" src="http://scripts.hashemian.com/js/visitorIPHOST.js.php"></script> 
</head><body></body></html>