IE不能实现,NS可以用java实现
解决方案 »
- JSP文件为什么可以在IE中正常打开不可以在Chrome中打开
- 新手求个自动切换的JSTAB特效
- 正则表达式官方教程{只供了解,会用至上}
- 回家过年,散分,顺便讨论Javascript字符串连接效率问题
- 有人用过 Lytebox 效果吗? 想在一个frame中使用Lytebox ,可是不能出现效果
- 如何利用JAVASCRIPT获取地址栏里的变量再将变量转成另外一个地址?
- 求助!!TextBox控件内数据换行(StringBuilder.Append的換行問題)
- 如何在网页中输入一些特殊的数学、物理、化学公式??????
- 如何实现www.dangdang.com上面层显示的动画效果?
- 关于多个类似名下拉选择框动态选中问题
- 怎么用javascript判断访问此网页的ip来源啊?
- 请问如何读windows注册表信息?
that by calling into Java:
var localhost = java.net.InetAddress.getLocalHost();
var hostname = localhost.getHostName();
var hostIP = localhost.getHostAddress(); alert('You are visiting from host ' + hostname
+ ' with ip address ' + hostIP);The only way with IE to use Java is an applet but the above code
(transcribed into Java) run in an applet is reported to return
localhost
for the hostname respectively
127.0.0.1
for the ip address.So all you can do for IE (and Opera and NN6) is to use server side
assists meaning a cgi script or php script dynmically returning the
REMOTE_ADDR cgi variable. I have set up such an assists at
http://www.csdn.net/jshelper/ipAddress.php
which returns a statement of the form
var ipAddress = '123.123.123.123;
so that a script can then access the variable
ipAddress
to read the value e.g.<HTML>
<HEAD>
<SCRIPT SRC="http://www.csdn.net/jshelper/ipAddress.php">
</SCRIPT>
</HEAD>
<BODY>
<SCRIPT>
document.write(ipAddress)
</SCRIPT>
</BODY>
</HTML>
TempBatchFileName="c:\temp\Tempfile.bat"Const ForReading = 1, ForWriting = 2, ForAppending = 3
set oFileSystem = CreateObject("Scripting.FileSystemObject")
Set oFile = oFileSystem.CreateTextFile(TempBatchFileName, True)
oFile.WriteLine "cd\" & chr(13) & chr(10) & "ipconfig /all > " & TempFileName
oFile.Close
set oFile=nothingset oShell=CreateObject("WScript.Shell")
iReturnValue=oShell.run(TempBatchFileName,1,true)set oFile = oFileSystem.OpenTextFile(TempFileName, ForReading)
sIPString=oFile.ReadAll
msgbox sIPString
oFile.Close
set oFile=nothingoFileSystem.DeleteFile TempBatchFileName,true
oFileSystem.DeleteFile TempFileName,trueset oFileSystem=nothing
set oShell = nothing</script>
<script>
alert(winsock1.localHostName)
alert(winsock1.localIP)
</script>