Mar*_*arc 11 javascript ajax google-chrome
我已经在 83 版上更新了 Chrome,但我的一些使用“Ajax 上传”组件(更多信息见下文)的表单无法正常工作。我已阅读新版本 ( https://developers.google.com/web/updates/2020/05/nic83 )的问题,但找不到与表单、iframe、文件、ajax 或帖子相关的任何内容。
我会尝试在 fiddler 上发布一个示例,但我想知道是否有人对此有所了解。
换句话说,在其他表单上,我有一个多文件拖放上传器 (dropzone.js),它工作正常,但转换起来并不容易,我需要一个快速的解决方案。
一个虚拟样本(我没有任何沙箱来测试上传):https : //jsfiddle.net/drvespa/7ue8k94r/3/
我将图书馆发布在https://filebin.net/8sgsmq7sh14m0qen 上:
/**
* Ajax upload
* Project page - http://valums.com/ajax-upload/
* Copyright (c) 2008 Andris Valums, http://valums.com
* Licensed under the MIT license (http://valums.com/mit-license/)
* Version 3.6 (26.06.2009)
*/
Run Code Online (Sandbox Code Playgroud)
Kai*_*ido 12
问题是该库正在创建一个带有src
属性的 <iframe>,并load
在它完成后立即侦听该 iframe的事件。
/**
* Creates iframe with unique name
*/
_createIframe: function () {
// unique name
// We cannot use getTime, because it sometimes return
// same value in safari :(
var id = getUID();
// Remove ie6 "This page contains both secure and nonsecure items" prompt
var iframe = toElement('<iframe src="javascript:false;" name="' + id + '" />');
iframe.id = id;
iframe.style.display = 'none';
d.body.appendChild(iframe);
return iframe;
},
Run Code Online (Sandbox Code Playgroud)
然后在submit
方法中
var iframe = this._createIframe();
// some synchronous operations
addEvent(iframe, 'load', function (e) { // ...
Run Code Online (Sandbox Code Playgroud)
由于这个 iframe 有一个src
属性,Chrome 将开始它的加载,并且由于它src
是一个假 url,这个操作实际上是同步解析的,这意味着加载事件已经设置为在下一次事件循环迭代时触发。
/**
* Creates iframe with unique name
*/
_createIframe: function () {
// unique name
// We cannot use getTime, because it sometimes return
// same value in safari :(
var id = getUID();
// Remove ie6 "This page contains both secure and nonsecure items" prompt
var iframe = toElement('<iframe src="javascript:false;" name="' + id + '" />');
iframe.id = id;
iframe.style.display = 'none';
d.body.appendChild(iframe);
return iframe;
},
Run Code Online (Sandbox Code Playgroud)
所以load
这个库接收的一个事件是初始加载事件,一个空文档,而不是真正的请求。
要解决这个问题,您只需src="javascript:false;"
要从库代码中删除它:https : //jsfiddle.net/9phxmqjw/
归档时间: |
|
查看次数: |
3858 次 |
最近记录: |