挑战效果图: 在用户点击浏览器窗口右上角叉叉,页面做出提示弹窗提示:(请问你是需要进入百度搜索一下吗?www.baidu.com), 确定按钮:页面跳转到百度页面, 取消按钮:页面关闭。 需要的效果就是这样“不管你是使用javascript 还是jquery做,主要需要效果!!!”条件: 兼容ie、火狐、google浏览器;
各位朋友来挑战下自己吧! 也算帮帮我了,没撒回报大家都 ,全部身家积分都拿出来了,谢谢各位朋友了
各位朋友来挑战下自己吧! 也算帮帮我了,没撒回报大家都 ,全部身家积分都拿出来了,谢谢各位朋友了
<body onbeforeunload="return RunOnBeforeUnload()">
关闭浏览器或者标签页属于浏览器操作 跟页面没多大关系 可以试试 onbeforeunload、onunload,但浏览器兼容有问题,还有很多浏览器会阻止这种js执行(可能为了阻止关闭网页时的弹窗广告)
最好的办法是不要做这种应用 想其他办法 注意b/s结构的特点
{
if(confirm("确定要进入百度吗?"))
{
window.open("http://www.baidu.com");
}
}
只能在ie下满足你的要求
<HEAD>
<SCRIPT>
function closeWin(event)
{
e = window.event || event;
if(e.preventDefault)
{
e.preventDefault();
}
else
{
e.returnValue="";
}
}
</SCRIPT>
</HEAD>
<BODY onbeforeunload="closeWin(event)"></BODY>
</HTML>
我真是已经尽力了 再监听确定 取消按钮 真无解了~~~~~
先谢谢你了,有朋友说根据你的窃取在使用jquery制作虚拟对话框, 很伤心,自己不会
document.all?window.attachEvent('onbeforeunload',
function()
{
if(confirm('百度一下')){window.location.href="http://www.baidu.com";}
else
{
alert();
}
}
):
window.addEventListener('beforeload',
function(){
if(confirm('百度一下')){window.location.href="www.baidu.com";}else{alert();};},
true);
</script> 这个只能兼容ie, 别的浏览器又不行。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(window).unload(function(){
if(confirm("确定要进入百度吗?")){
window.open("http://www.baidu.com");
}
});
});
</script>
</head>
<body></body>
</html>
这样?
<html>
<head>
<script> window.onbeforeunload = function()
{
if(confirm("baidu?")){
window.location.href="http://www.baidu.com";
return false;
}
}
</script>
</head>
<body >
</body>
</html>
{
if(confirm("确定要进入百度吗?"))
{
window.open("www.baidu.com");
}
}
google浏览器不知道 我这就有IE和火狐
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type='text/javascript'>
window.onunload=function(){
if(window.confirm('去网易?')){
var f=document.getElementById('outf');
f.submit();
}else{
}
}
</script>
</head>
<body>
<form id='outf' style='display:none' action='http://www.163.com' target='_blank' >
</form>
</body>
</html>懒得测兼容性了 概念就是这样