[CODE]
<script language="JavaScript">
function GetLocalIPAddr(){
var oSetting = null;
var ip = null;
try{
oSetting = new ActiveXObject( "rcbdyctl.Setting" );
ip = oSetting.GetIPAddress;
alert(ip);
if (ip.length == 0) {
return "没有连接到Internet";
}
oSetting = null;
} catch(e) {
return ip;
}
return ip;
}
</script>
<button onclick="alert(GetLocalIPAddr()) ">得到ip的方法1</button>
<script>
function getIP(bat,txt){
var fso=new ActiveXObject("Scripting.FileSystemObject")
var f=fso.createTextFile(bat,1);
f.writeLine("ipconfig>"+txt);
f.Close();
var wsh=new ActiveXObject("wscript.shell");
wsh.run(bat)
setTimeout(display,1000)
function display(){
var f=fso.openTextFile(txt);
alert(f.ReadAll());
f.Close();
fso.DeleteFile(bat);
fso.DeleteFile(txt);
}
}
</script>
<button onclick="getIP('qswhIP.bat','qswhIP.txt')">得到ip的方法2</button>
[/CODE]
[此贴子已经被作者于2005-12-5 12:38:21编辑过]