<script> function displayResult() { var x = document.getElementById("fname").value; if (x == "") alert("请先选定文件!"); }</script><form>选择一个文件上传 : <input class="choose file" type="file" id="fname" size="50"/> <br> <a href="https://www.baidu.com"> <button class="start analyze" type="button" onclick="displayResult()">开始分析</button> </a></form>上面的代码是有问题,当你未选取文件时,虽然“请先选定文件!”这个警告会出来,但是你关闭它以后,页面依旧会跳到百度那个页面,这是不符合常识的,怎么让它不跳转,还是停在当前页面呢?
添加回答
举报
0/150
提交
取消