Chrome设置
chrome://settings/(com+,)-> 隐私设置 -> 内容设置
代码块
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title> /</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
</head>
<body>
<!--方法1 submit,窗口被浏览器拦截-->
<script type="text/javascript">
var get_standar_post = function(url,agrs){
var form = $("<form method='post' target='_blank'></form>");
form.attr({"action":url});
for (arg in agrs) {
var input = $("<input type='hidden'>");
input.attr({"name":arg});
input.val(agrs[arg]);
form.append(input);
}
form.submit();
};
//get_standar_post('http://baidu.com/',{ name: 'zyt' });
</script>
<!--方法2 trigger,窗口被浏览器拦截-->
<form id="form2" method='post' target='_blank' action="3i23ysnmnd">
<input type="text" name="key" value="123">
<input id="submit" type="submit" name="submit">
</form>
<script type="text/javascript">
$('#submit').on('click',function(){
alert(1212);
});
$(function() {
//$('#submit').trigger('click');
//http://www.css88.com/jqapi-1.9/trigger/
//naturally-occurring event
//浏览器会拦截窗口,是把窗口当成js弹出广告,造成的原因是如果是用户主动触发,一般不会拦截,用js触发的,一般都会拦截。
})
</script>
<!--方法3 用户主动触发 未拦截-->
<form id="form3" method='post' target='_blank' action="333333">
<input type="text" name="key" value="123">
</form>
<script type="text/javascript">
$(document.body).on('click',function(){
$("#form3").submit();
//有用户的实际点击,哪怕不是在form3内的submit按钮,也可以不被拦截
})
</script>
<!--方法4 window.open, 拦截,但是做出提示-->
<form id="form4" method='post' target='_blank' action="44444444">
<input type="text" name="key" value="123">
</form>
<script type="text/javascript">
//http://blog.csdn.net/nature_fly088/article/details/8219345
$(function(){
var flag = window.open('',"","");
if(flag==null) {
alert("您的浏览器启用弹出窗口过滤功能!\n\n请暂时先关闭此功能!") ;
}
$("#form4").submit();
window.close();
})
</script>
</body>
</html>
网友评论