如何修复处理 iframe 的此错误
How to fix this error dealing with an iframe
当用户单击"取消"按钮时,我正在尝试阻止文件上传。为此,我正在考虑停止 iframe 内的传输。问题是能够正确编码。以下是我试图实现的代码,但是当我单击"取消"按钮时出现此错误:
Uncaught exception: [Exception.... “Not enough arguments [nslDOMHTML.Document.execCommand]” nresult: “0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)” location: “JS frame;; https://......../QandATable.php = <TOP_LEVEL> ;; line 765” data: no]
首先如何修复此错误,其次如何正确编写下面的代码,以便在单击"取消"按钮时停止iframe内的传输?
下面是开始上传文件的 startImageUpload() 函数。在该函数中,有在单击"取消"按钮时处理"取消"按钮的功能;
function startImageUpload(imageuploadform){
$(".imageCancel").click(function() {
$('.upload_target')[0].contentwindow
if ($('.upload_target')[0].contentWindow.document.execCommand)
{ // IE browsers
$('.upload_target')[0].contentWindow.document.execCommand('Stop');
}
else
{ // other browsers
$('.upload_target')[0].contentWindow.stop();
}
return stopImageUpload();
});
return true;
}
下面是由 iframe 组成的表单代码:
var $fileImage = $("<form action='imageupload.php' method='post' enctype='multipart/form-data' target='upload_target' onsubmit='return startImageUpload(this);' class='imageuploadform' >" +
"Image File: <input name='fileImage' type='file' class='fileImage' /></label><br/><br/><label class='imagelbl'>" +
"<input type='submit' name='submitImageBtn' class='sbtnimage' value='Upload' /></label>" +
"</p><p class='imagef1_cancel' align='center'><label>" +
"<input type='button' name='imageCancel' class='imageCancel' value='Cancel' /></label></p>" +
"<iframe class='upload_target' name='upload_target' src='#' style='width:0;height:0;border:0px;solid;#fff;'></iframe></form>");
根据 MSDN,不支持Stop
命令。
相关文章:
- 动态创建的iframe中的window.onerror在lne 0处给出脚本错误
- 可以'iframe的父窗口中发生捕获错误
- 尝试从我的 chrome 扩展程序访问 gmail 中的 iframe 时出现未定义的错误,但不是从开发者控制台访问
- 未捕获的语法错误:使用 iFrame 时出现意外的令牌 }
- 如何捕获 iframe 内的 img 标记返回的 404(未找到)错误
- 为什么当我尝试为iframe-src属性构建URL时,AngularJS会抛出错误
- 当我尝试使用jquery获取iframe的内容时,我得到了错误.请帮我解决
- 使用 iframe 时的 JavaScript 错误
- TypeError: e.fixers 是动态加载的 iframe 上无前缀的未定义错误
- 通过 IFrame 更新文件时的错误处理
- 如何捕获 iframe 加载错误
- Youtube IFrame Internet Explorer上的Fancybox错误
- 水星编辑器 0.9 - 内容 iFrame 位于编辑器控件后面,高度错误
- 关闭包含YouTube电影的Fancybox-iframe时出现IE JS错误
- Ajax Iframe 创建(Spotify widget):x 帧错误
- 来源较少的iframe错误火狐
- 刷新 iframe 错误
- 如果在小型设备上,请将 iframe 替换为错误文本
- 如何修复处理 iframe 的此错误
- 用Angular JS加载iframe src-错误