首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

JS字符串连接与自动获取服务器IP有关问题

2012-03-27 
JS字符串连接与自动获取服务器IP问题在**.js文件中var __cc_sys_url http://192.168.0.42:8081/count//

JS字符串连接与自动获取服务器IP问题
在**.js文件中
var __cc_sys_url ="http://192.168.0.42:8081/count/"
//var __cc_sys_url ="http://"+window.location.host+":"+window.location.port+"/count/"
及***.asp文件中
<script language="JavaScript" 
  src="http://192.168.0.42:8081/count/**.js"> 
</script> 

我想改成自动获取当前服务器IP及端口号
所以改成了如下:
在**.js文件中
var __cc_sys_url ="http://"+window.location.host+":"+window.location.port+"/count/"
及***.asp文件中
<script language="JavaScript" 
  src="http://"+window.location.host+":"+window.location.port+"/count/**.js"> 
</script>

这样改不行,莫非把window.location改成document.location ,大家帮帮忙吧,谢谢了

[解决办法]
获取服务器IP: <%=Request.ServerVariables("LOCAL_ADDR")%>

端口号:<%=Request.ServerVariables("SERVER_PORT")%>
[解决办法]

HTML code
JS文件<script type="text/javascript">var __cc_sys_url = "http://"+window.location.host + ":" + window.location.port+"/count/" ;</script>asp文件<%url = "http://" + Request.ServerVariables("HTTP_HOST") + ":" + Request.ServerVariables("SERVER_PORT") + "/count/**.js"%><script type="text/javascript" src="<%=url%>"></script>
[解决办法]
探讨
获取服务器IP: <%=Request.ServerVariables("LOCAL_ADDR")%>

端口号: <%=Request.ServerVariables("SERVER_PORT")%>

热点排行