Javascript .click() not firing in safari -
i have file upload input in application , i'm using link , javascript open dialog.
<a class="uploadlink" style="cursor:pointer" onclick="document.getelementbyid('file').click()">open</a> <input type="file" name="file" id="file" style="display:none" onchange="document.getelementbyid('txt').value = this.value"/>
my code working in browsers , devices except safari , apple devices. when click link , check link console doesn'teven register error. can suggest solution?
since had display:none
in safari not not rendered not referenced. have changed code follows.
jquery solution
<a class="uploadlink" style="cursor:pointer" onclick="$('#file').trigger('click');">open</a> <input type="file" name="file" id="file" style="opacity:0" onchange="document.getelementbyid('txt').value = this.value"/>
javascript solution
<a class="uploadlink" style="cursor:pointer" onclick="document.getelementbyid('file').click();">open</a>
it working in safari.
Comments
Post a Comment