document.write(window.location.host)
document.write(window.location.hostname)

解决方案 »

  1.   

    IP地址:<%=request.ServerVariables("REMOTE_ADDR")%>
    主机域名:<%=request.ServerVariables("SERVER_NAME")%>
      

  2.   

    IP地址:<%=request.ServerVariables("REMOTE_ADDR")%>
    主机域名:<%=request.ServerVariables("SERVER_NAME")%>是这样的吧,好像有点记得
      

  3.   

    2楼的,好像不行哦。
    我在一个按钮的事件里这样写的:
    alert(window.location.host);
    alert(window.location.hostname);
    结果出来的对话框里,是空白的。3楼4楼,你们这个怎么用啊,我对网页制作不是很熟悉。
      

  4.   

    楼上的,我已经有现成的HTML文件了,本来要求不高的,就这么一个对我来说比较难的问题。要是为了这个把页面做成ASP的话,估计又会带来新的问题。因为我对WEB这块不熟,用得也少。
      

  5.   

    window.location.host  肯定可以的,你是不是在本地运行的
      

  6.   

    在jsp中的话是这样得到的
    IP地址:<%=request.getRemoteAddr()%>
    主机名:<%=request.getServerName()%>
    在asp中就不知道了啊.....