ajax回调后打开新窗口给ie拦截掉了 使用ajax回调后,通过js点击某个超链接(target为_blank),结果给ie自带的弹出窗口阻止程序拦截掉了这种问题如何解决 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用js要激活link的click事件是个不安全行为,所以会被阻止掉,建议不要采用这种js激活click事件的方法 只能更改ie设置,ie--工具--internet选项--隐私--设置,将你的服务器列入允许弹出窗口的清单中 如果不使用ajax,直接通过js来点击,是不拦截,只要一回调就不行了让用户更改设置,肯定是不用考虑的现在只是考虑换流程,问题是与服务端交互是要的,弹出新窗口也是要的,不知道有什么好的方法 应该不会吧?使用ajax打开新窗口不是用JS吗?既然都是JS怎么AJAX的JS就被拦截了?你的AJAX是不是跨域了? <script> function linkClick(url,linkid){ var but = document.getElementById(linkid); but.href = url; but.target = "_blank"; but.click(); } function ajax(url,tempCallback){ var method="GET"; if(window.XMLHttpRequest){ var xmlhttp = new XMLHttpRequest(); }else if(window.ActiveXObject){ try{ var xmlhttp= new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } } if (xmlhttp == null) return; xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState == 4) { if (xmlhttp.status >= 200 && xmlhttp.status < 300) { tempCallback(url,xmlhttp.responseText); } } }; xmlhttp.open(method, url, true); xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"); xmlhttp.setRequestHeader("If-Modified-Since","0"); xmlhttp.send(null); }window.onload=function(){ ajax("http://www.baidu.com",function(url,ttt){ alert(ttt); linkClick(url,"test0") }) ajax("http://www.google.com.hk/",function(url,ttt){ alert(ttt); linkClick(url,"test1") }) }</script><a id="test0">百度</a><a id="test1">google</a> ajax就是用的js呀,也没有跨域,所以奇怪了9楼的代码跑不起来 提示拒绝访问 把你AJAX回调函数里内容贴出来看看 getDivOk为回调函数function getDivOk(){ if (xmlHttp.readyState == 4) { var response = xmlHttp.responseText; try{ document.getElementById("logdiv").innerHTML=response; showClickContent(); }catch(exception){} } }function showClickContent(){ document.getElementById("openref").href=WebGoUrl; document.getElementById("openref").click(); } function getDivOk(){ if (xmlHttp.readyState == 4&&(xmlHttp.status==200||xmlHttp.status==0)){ var response = xmlHttp.responseText; try{ document.getElementById("logdiv").innerHTML=response; showClickContent(); window.open(WebGoUrl,'ajaxopen')//这里直接打开 }catch(exception){} }}function showClickContent(){ document.getElementById("openref").href=WebGoUrl; //document.getElementById("openref").click();//多此一举不是吗? //other codes................} 之所以不用open就是怕被拦截掉,所以用超连接来做的现在是通过点击超链接都给ie拦截了,open就更不用说了 做web开发要站在客户的立场上看待这个问题比如你是客户你当然不希望更改自己的浏览器设置了所以呢还是想办法解决,不要期望更改客户端的浏览器设置,人家就是不改,你能怎么着?!客户就是客户建议用div层的方式去实现我之前有做过一个系统登录的强制通知弹出框也就是用户一登录就能看到弹出信息也是遇到了楼主的问题,会被ie拦截,或是用户ie设置屏蔽掉了最后我用div层的方式实现弹出窗口效果现在不管怎么设置也拦截不到我那弹出窗口以上是个人一点建议,仅供参考 弹出的窗口已经不是本网站的,所以用div的办法不行 添加 Mark of the Web 命令 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><!-- saved from url=(0014)about:internet --><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><script type="text/javascript">window.open("http://www.baidu.com","_blank");</script></head><body></body></html> 点radio怎么用javascript控制div层,急求,在线等高手解答 IE(6,7)如何判断弹出窗口是否包含状态栏,地址栏,工具栏等 关于HTML中title标签 一个带 js 的链接在 div 中无效的问题,请达人帮忙 javascript fopen() 不作用? 求一个可以自定义黑名单或者白名单的表单输入JS验证函数! dom添加节点问题 问高手:JS如何实现像google首页搜索的效果 能否动态生成对象名? 哪位能说一下this作为方法参数的用法? js 键值对问题 虽有在CSS中定义div标签的WIDTH样式,为什么用js取不出来相应的值??
让用户更改设置,肯定是不用考虑的现在只是考虑换流程,问题是与服务端交互是要的,弹出新窗口也是要的,不知道有什么好的方法
function linkClick(url,linkid){
var but = document.getElementById(linkid);
but.href = url;
but.target = "_blank";
but.click();
} function ajax(url,tempCallback){
var method="GET";
if(window.XMLHttpRequest){
var xmlhttp = new XMLHttpRequest();
}else if(window.ActiveXObject){
try{ var xmlhttp= new ActiveXObject("Msxml2.XMLHTTP");
}catch(e){ var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
if (xmlhttp == null) return;
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4) {
if (xmlhttp.status >= 200 && xmlhttp.status < 300) {
tempCallback(url,xmlhttp.responseText);
}
}
};
xmlhttp.open(method, url, true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
xmlhttp.setRequestHeader("If-Modified-Since","0");
xmlhttp.send(null);
}
window.onload=function(){
ajax("http://www.baidu.com",function(url,ttt){
alert(ttt);
linkClick(url,"test0")
})
ajax("http://www.google.com.hk/",function(url,ttt){
alert(ttt);
linkClick(url,"test1")
})
}
</script><a id="test0">百度</a>
<a id="test1">google</a>
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
try{
document.getElementById("logdiv").innerHTML=response;
showClickContent();
}catch(exception){}
}
}function showClickContent()
{
document.getElementById("openref").href=WebGoUrl;
document.getElementById("openref").click();
}
function getDivOk(){
if (xmlHttp.readyState == 4&&(xmlHttp.status==200||xmlHttp.status==0)){
var response = xmlHttp.responseText;
try{
document.getElementById("logdiv").innerHTML=response;
showClickContent();
window.open(WebGoUrl,'ajaxopen')//这里直接打开
}catch(exception){}
}
}function showClickContent(){
document.getElementById("openref").href=WebGoUrl;
//document.getElementById("openref").click();//多此一举不是吗?
//other codes................
}
现在是通过点击超链接都给ie拦截了,open就更不用说了
比如你是客户你当然不希望更改自己的浏览器设置了
所以呢还是想办法解决,不要期望更改客户端的浏览器设置,人家就是不改,你能怎么着?!客户就是客户建议用div层的方式去实现
我之前有做过一个系统登录的强制通知弹出框
也就是用户一登录就能看到弹出信息
也是遇到了楼主的问题,会被ie拦截,或是用户ie设置屏蔽掉了最后我用div层的方式实现弹出窗口效果
现在不管怎么设置也拦截不到我那弹出窗口以上是个人一点建议,仅供参考
弹出的窗口已经不是本网站的,所以用div的办法不行
<!-- saved from url=(0014)about:internet -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
window.open("http://www.baidu.com","_blank");
</script>
</head><body>
</body>
</html>