Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browser freezing after selecting file in input field

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>
like image 897
SiliconValley Avatar asked Oct 12 '16 03:10

SiliconValley


1 Answers

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.

like image 132
Michael Chicherin Avatar answered Nov 01 '22 13:11

Michael Chicherin