提交在 Windows 7 下的 Chrome 和 IE 中不起作用
我有一个使用 .net 创建的 Web 表单,并且在此表单中有一个框架,该框架的源代码来自另一个 HTML 页面(由 courselab 软件创建)。每当用户完成页面并单击提交按钮并正常退出时,或者每当用户基于 javascript 事件“onbeforeunload”导航离开页面时,我都会调用 javascript 代码。
在这两种情况下,代码都可以完美地使用
Firefox *两种情况下 Windows XP 上的 IE*
如果用户单击提交按钮(此提交按钮由调用 javascript 代码的 courselab 软件生成),它仍然可以在 CHROME 中工作,
但是如果用户离开 Web 表单,则会使用“onbeforeunload”调用此代码,并且代码会正确呈现,但永远不会触发提交输入。
类似地,在 Windows 7 上使用 IE 也不会触发此代码。
我还调用了表单的代码“onunload”,但仍然没有任何反应。
更新 浏览器8 火狐浏览器 3.6.1.3 Chrome 9.0.597.98
主要的 Web 表单具有以下内容
<div id="FOContent">
<iframe runat=server id="mainiframe" name="mainiframe" scrolling="no" frameborder="no"
width="1000" height="920"></iframe>
</div>
框架内容来自此 HTML 页面
<body style="margin-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;" onload="Run(true)" onunload="Shutdown()" onbeforeunload="Shutdown()" oncontextmenu="return false">
<div id="boardFrame" style="position:absolute;left:0px;top:0px;width:1000;height:700">
</div>
<div id="divEmail"></div>
</body>
调用“onunload”或“onbeforeunload”的 javascript 代码是
function LMSShutdown() {
if (submit_Var == false) {
var sAiccData = AICC_PrepareData(); // prepare data from the CourseLab
var strQuizResults
strQuizResults = "";
var nPos1 = sAiccData.indexOf("Score=");
nPos1 = nPos1 + 6;
var ePos1 = nPos1 + 2
var score = sAiccData.substring(nPos1, ePos1);
var sHTML = "";
var qTxt;
qTxt = ""
var qrStr = window.location.search;
var spQrStr = qrStr.substring(1);
var arrQrStr = new Array();
// splits each of pair
var arr = spQrStr.split("&");
for (var i = 0; i < arr.length; i++) {
// splits each of field-value pair
var index = arr[i].indexOf("=");
var key = arr[i].substring(0, index);
var val = arr[i].substring(index + 1);
var id1
var id2
if (key == "")
{key = "Q"+i}
qTxt = qTxt + "&" + key + "=" + val;
if (i == 0)
{ id1 = val; }
else
{ id2 = val; }
}
// saves each of field-value pair in an array variable
sHTML += '<FORM id="formQuiz" method="POST" action="../../../StudentView/QuizProcess.aspx?submit_Var=' + 'false' + '&score=' + score + qTxt + '">';
var spQrStr = g_arVars["writing"];
var arrQrStr = new Array();
// splits each of pair
var arr = spQrStr.split("@@@");
for (var i = 0; i < arr.length; i++) {
// splits each of field-value pair
var index = arr[i].lastIndexOf(":");
var key = arr[i].substring(0, index);
var val = arr[i].substring(index + 1);
if (key != "")
{qTxt = qTxt + "&" + key + "=" + val;
sHTML += '<INPUT TYPE="hidden" NAME="' + key + '" VALUE=\'' + val + '\'>';
}
}
sHTML += '<br><input name="btnSubmit" id="btnSubmit" type="button"><br>';
sHTML += '</FORM>';
document.getElementById("divEmail").innerHTML = sHTML;
document.getElementById("formQuiz").submit();
submit_Var = true;
}
}
QuizProcess.aspx 页面的 HTML 内容不多,但有 vb 。 net 代码将数据存储到数据库
问题是,在不同平台上的所有浏览器中都调用了函数 LMSShutdown,但表单 QuizProcess 并未仅在(Windows XP 或 7 上的 chrome)和(使用 Windows 时的 IE 8)中提交7) 奇怪的是,在 Windows XP 上的 IE 8 中运行良好。
I have a web form created using .net and in this form has a frame which has its source from another HTML page (created by courselab software). I call a javascript code whenever the user completes the page and click a submit button and exits normally or whenever the user navigates away from the page based on the javascript event "onbeforeunload".
The code works just perfectly using
Firefox in both cases
*IE on Windows XP in both cases*
Still it works in CHROME if the user clicked on the submit button (this submit button generated by courselab software which calls the javascript code),
but if the user navigates away from the web form, this code is being called using the "onbeforeunload" and the code renders correctly but the submit input is never fired.
Similary this code does not fire using IE on Windows 7.
I have also called the code "onunload" of the form, but still nothing happens.
Update
IE 8
Firefox 3.6.1.3
Chrome 9.0.597.98
the main web form has the following
<div id="FOContent">
<iframe runat=server id="mainiframe" name="mainiframe" scrolling="no" frameborder="no"
width="1000" height="920"></iframe>
</div>
The frame content comes from this HTML page
<body style="margin-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;" onload="Run(true)" onunload="Shutdown()" onbeforeunload="Shutdown()" oncontextmenu="return false">
<div id="boardFrame" style="position:absolute;left:0px;top:0px;width:1000;height:700">
</div>
<div id="divEmail"></div>
</body>
And the javascript code being called for "onunload" or "onbeforeunload" is
function LMSShutdown() {
if (submit_Var == false) {
var sAiccData = AICC_PrepareData(); // prepare data from the CourseLab
var strQuizResults
strQuizResults = "";
var nPos1 = sAiccData.indexOf("Score=");
nPos1 = nPos1 + 6;
var ePos1 = nPos1 + 2
var score = sAiccData.substring(nPos1, ePos1);
var sHTML = "";
var qTxt;
qTxt = ""
var qrStr = window.location.search;
var spQrStr = qrStr.substring(1);
var arrQrStr = new Array();
// splits each of pair
var arr = spQrStr.split("&");
for (var i = 0; i < arr.length; i++) {
// splits each of field-value pair
var index = arr[i].indexOf("=");
var key = arr[i].substring(0, index);
var val = arr[i].substring(index + 1);
var id1
var id2
if (key == "")
{key = "Q"+i}
qTxt = qTxt + "&" + key + "=" + val;
if (i == 0)
{ id1 = val; }
else
{ id2 = val; }
}
// saves each of field-value pair in an array variable
sHTML += '<FORM id="formQuiz" method="POST" action="../../../StudentView/QuizProcess.aspx?submit_Var=' + 'false' + '&score=' + score + qTxt + '">';
var spQrStr = g_arVars["writing"];
var arrQrStr = new Array();
// splits each of pair
var arr = spQrStr.split("@@@");
for (var i = 0; i < arr.length; i++) {
// splits each of field-value pair
var index = arr[i].lastIndexOf(":");
var key = arr[i].substring(0, index);
var val = arr[i].substring(index + 1);
if (key != "")
{qTxt = qTxt + "&" + key + "=" + val;
sHTML += '<INPUT TYPE="hidden" NAME="' + key + '" VALUE=\'' + val + '\'>';
}
}
sHTML += '<br><input name="btnSubmit" id="btnSubmit" type="button"><br>';
sHTML += '</FORM>';
document.getElementById("divEmail").innerHTML = sHTML;
document.getElementById("formQuiz").submit();
submit_Var = true;
}
}
The QuizProcess.aspx page has not much in HTML, but it has vb .net code to store data to database
The issue is that the function LMSShutdown is being called in all browsers on different platforms, but the form QuizProcess is not being submitted only in (chrome on Windows XP or 7 ) and in (IE 8 when using Windows 7) strangely works fine in IE 8 on Windows XP.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了类似的问题,如下所述: http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/00b88378-a7f1-4148-9587-1ff17d6fa728
本质上,在 Windows 7 和 IE9 中,子表单被拒绝访问提交调用。
诀窍是让家长打电话。将 onbeforeunload 事件放在父表单上,它会找到框架并从那里找到表单,并允许调用提交。
I had a similar issue, described here: http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/00b88378-a7f1-4148-9587-1ff17d6fa728
Essentially it seems that in Windows 7 and also in IE9, a child form is denied access to the submit call.
The trick is to get the parent to do the call. Put the onbeforeunload event on the parent form and it find the frame and from there the form and it is allowed to call the submit.
检查或禁用您的扩展程序,看看它是哪一个。我以前也遇到过 AdBlock 的情况。
Check, or disable your extensions, and see which one it is. I had it with AdBlock happen before.