有个windows2008的服务器,在这台服务器上ie8测试页面没问题,但是在别的电脑上测试的话会有一个问题,别的电脑上都是ie7,ie6。
代码:window.onbeforeunload = onbeforeunload_handler;
window.onunload = onunload_handler;
function onbeforeunload_handler(){
if(event.clientX>document.body.clientWidth && event.clientY<0||event.altKey)
{
if(setMsgFlag)
{
var warning="离开页面会自动提交试卷!";
return warning;
}
}
else
{
setMsgFlag=false;
}
}
function onunload_handler(){
if(setMsgFlag)
{
SaveValue();
}
}
function SaveValue(rowCount)
{
if(rowCount > 0)
{
alert("答卷提交成功!");
setMsgFlag=false;
window.close();
window.open("../testhistory/TestHistorySearch.aspx");
}
else
{
alert("答卷提交失败!");
return;
}
}}如果在一个按钮里直接用SaveValue()方法,没问题,window。open可以打开新页面,但是如果点击页面右上角的关闭按钮的话,window。open就不能打开,为什么呢,请大家指教。
代码:window.onbeforeunload = onbeforeunload_handler;
window.onunload = onunload_handler;
function onbeforeunload_handler(){
if(event.clientX>document.body.clientWidth && event.clientY<0||event.altKey)
{
if(setMsgFlag)
{
var warning="离开页面会自动提交试卷!";
return warning;
}
}
else
{
setMsgFlag=false;
}
}
function onunload_handler(){
if(setMsgFlag)
{
SaveValue();
}
}
function SaveValue(rowCount)
{
if(rowCount > 0)
{
alert("答卷提交成功!");
setMsgFlag=false;
window.close();
window.open("../testhistory/TestHistorySearch.aspx");
}
else
{
alert("答卷提交失败!");
return;
}
}}如果在一个按钮里直接用SaveValue()方法,没问题,window。open可以打开新页面,但是如果点击页面右上角的关闭按钮的话,window。open就不能打开,为什么呢,请大家指教。
解决方案 »
- 用了 CJL.0.1.min.js 文件后与现有的JS冲突~
- 求教
- jquery小问题
- ---------------------------这5行代码哪里错了??? 显示b为定义??-------------------------------
- 一个正则表达式写法?
- 如何对应:随机连续播放图片,在点某张图的时候出现隐藏层,层中显示对应的大图象。如何对应
- <script src=...后面能不能接受客户端脚本的变量,在线急求!!!
- 用javascript怎样实现让下拉列表框选中某一项
- 关于prompt对话框的用法
- 聊天室的输入框怎么处理的???
- google浏览器 怎么取fileupload路径
- 如何用js获得表格一共有多少列
ajax的方法就不错
<input type="button" onclick="SaveValue();">这样调用却可以,但是点击了右上角关闭按钮后,触发了window.beforeunload()和 window.unload() 后,就不能用了呢
测试的时候需要关闭弹出窗口阻止程序。测试环境是ie7,ie8
<script>
window.onbeforeunload = onbeforeunload_handler;
window.onunload = onunload_handler;
function onbeforeunload_handler(){
setMsgFlag=true
}
function onunload_handler(){
if(setMsgFlag)
{
SaveValue();
}
}
function SaveValue(rowCount)
{
window.open("http://dotnet.aspx.cc/")
}
</script>