var xmlHttp
if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Microsoft.xmlHTTP")
}
else if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Msxml2.xmlHTTP.4.0")
}
else if(window.ActiveXObject){
xmlHttp = new ActiveXObject("Msxml2.xmlHTTP")
}
else if(window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest()
}else{
alert("You browser security setting not allow to create XMLHTTPP object.")
}
xmlHttp.open("get", xmlURL, false)
xmlHttp.send(null)
在a标签上绑定事件即可。代码如下:
window.onload = function () {
document.getElementsByTagName('a')[0].onclick = function (ev) {
alert('我被单击了')
ev.preventDefault()//w3c规范,如火狐、chrome等
//event.returnValue = false//ie下,不过ie8、可以用上面的那个
alert('我被阻止了')
}
}
试下这样行不行:<a href="javascript:location.href = encodeURL('<%=request.getContextPath()%>/food/franchiser!ss.action?province=${dh.province}')"><%=request.getContextPath()%>/food/franchiser!ss.action?province=${dh.province}</a>