编辑下面的代码:【加编码】
<html> <head> <script> function displayResult() { var x=document.getElementById("fname").accept; alert(x); } </script> </head> <body> <form id="form1"> 选择一个文件上传: <input type="file" id="fname" size="50" accept="video/*"> </form> <button type="button" onclick="displayResult()">显示接收文件的类型</button> <p>目前所有主流浏览器都支持显示接收的文件类型!但是只有 Opera 和 Google Chrome 浏览器会过滤掉用户正在浏览的正确文件类型。</p> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂