用一张图片做链接,根据IP判断内外网,连到不同的页面
本帖最后由 lcy0604 于 2013-03-10 21:11:43 编辑
代码如下,点击图片链接后不报错,但地址栏只出现javascript:dingxiang()字样,页面一片空白。希望高手指点,谢谢!
<DIV class="QUIKE">
<script language=vbscript>
ipx=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
IF ipx="" Then ipx=Request.ServerVariables("REMOTE_ADDR")
function ipCheck(ip,startIp,endIp)
ipPart=split(ip,".")
startIpPart=split(startIp,".")
endIpPart =split(endIp,".")
if ipPart(0)&"."&ipPart(1)=startIpPart(0)&"."&startIpPart(1) then
if ipPart(2)>=startIpPart(2) and ipPart(2)<=endIpPart(2) then
ipCheck="true"
else
ipCheck="false"
end if
else
ipCheck="false"
end if
end function
function dingxiang(dingxiang)
if ipCheck(ipx,"172.20.0.1","172.20.255.254")="true" or ipCheck(ipx,"172.21.0.1","172.21.255.254 ")="true"
then
url="http://172.20.1.8"
window.open(url,dingxiang)
else
url="building.asp"
window.open(url,dingxiang)
end if
end function
</script>
<UL><a href="javascript:dingxiang()" target="_blank"><img src="Images/dzts.gif" alt="电子图书系统" border="0"/></a></UL>
</DIV>
------解决方案--------------------<%
Dim ip,ipx,url
ip=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If ip="" Then ip=Request.ServerVariables("REMOTE_ADDR")
ipx=Left(ip,7)
If ipx="172.20." Or ipx="172.21." Then
url="http://172.20.1.8"
Else
url="building.asp"
End If
Response.write "<a href='"&url&"' target='_blank'><img src='Images/dzts.gif' alt='电子图书系统' border='0'/></a>"
%>
------解决方案--------------------Dim ip,ipx,url
ip=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If ip="" Then ip=Request.ServerVariables("REMOTE_ADDR")
ipx=Left(ip,7)
If ipx="172.20." Or ipx="172.21." Then
url="http://172.20.1.8"
Else
url="javascript:alert('电子图书系统只能内网开放,请绕行!');location='building.asp'"
End If
Response.write "<a href='"&url&"' target='_blank'><img src='Images/dzts.gif' alt='电子图书系统' border='0'/></a>"