在输入字段中选择文件后浏览器冻结 [英] Browser freezing after selecting file in input field

查看:47
本文介绍了在输入字段中选择文件后浏览器冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含输入文件字段的表单 [<input type="file" id="select-file" accept=".md"><label for="select-file">选择导入文件].它为更改事件 [$("#form").on("change", "#select-file", handler)] 定义了一个 jQuery 处理程序,一旦我选择了一个文件.

它可以在 Linux 上使用 Firefox 在工作和在家庭上使用 Firefox 和 Chrome 在 Windows 上完美运行.

在使用 Chrome 或 Firefox 的 Windows 中工作,选择文件后浏览器会冻结大约 8 秒.只有在此中断之后,我才能按下表单上的其他按钮,并且更改"事件会触发.

不考虑 Windows 和 work 不啮合的假设,冻结似乎与工作中可用的不同网络磁盘有关.任何人都可以建议我必须检查的内容并希望有一种避免冻结的方法吗?谢谢!

小例子:

<头><meta charset="utf-8"/><title>文件选择</title><script src="https://code.jquery.com/jquery-2.2.4.min.js"></script><身体><div id="import-form"><input type="file" id="select-file" accept=".md"><label for="select-file">选择一个文件</label><p id="selected-file">未选择文件</p>

<脚本>$("#import-form").on("change", "#select-file", function(e) {$("#selected-file").text(e.target.value.split('\\').pop());});</html>

解决方案

Chrome 在使用任何文件字段后冻结几秒钟.

那是因为我在快速访问"中有一个快捷方式;Windows 资源管理器中的菜单.此快捷方式已与网络共享的文件夹链接.我已删除此快捷方式,现在一切正常.

I have a form containing an input file field [<input type="file" id="select-file" accept=".md"><label for="select-file">Select import file</label>]. It has defined a jQuery handler for the change event [$("#form").on("change", "#select-file", handler)] to fire as soon as I selected a file.

It works flawlessly on Linux with Firefox at work and at home with Windows using Firefox and Chrome.

Instead at work with Windows using Chrome or Firefox, the browser freeze for about 8 sec after selecting the file. Only after this hiatus I can push other buttons on the form and the "change" event fires.

Discarding the hypothesis that Windows and work does not mesh, the freeze seems related to the different network disks available at work. Can anyone suggest what I have to check and hopefully a way to avoid the freeze? Thanks!

Small example:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>File Select</title>
    <script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
</head>
<body>
<div id="import-form">
    <input type="file" id="select-file" accept=".md">
    <label for="select-file">Select a file</label>
    <p id="selected-file">No file selected</p>
</div>
<script>
$("#import-form").on("change", "#select-file", function(e) {
    $("#selected-file").text(e.target.value.split('\\').pop());
});
</script>
</body>
</html>

解决方案

Chrome freezes for few seconds when after any use of file field.

It was because I had a shortcut in "Quick Access" menu in windows explorer. This shortcut has been linked with a folder shared by network. I've removed this shortcut and everything is good now.

这篇关于在输入字段中选择文件后浏览器冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆