2017-02-09 82 views
0

我的页面底部包含一个表单。当页面加载浏览器给焦点的形式,当我想要的是页面的顶部显示。页面加载时,如何防止关注表单(页面底部)?

形式为:

<section class="item" id="form_text"> 
    <form id="form" name="queryForm" action="proc_query.php" method="get"> 
     <input type="text" size="40" name="name" autofocus required placeholder="Name"><br><br> 
     <input type="text" size="40" name="phoneNum" placeholder="Phone No."><br><br> 
     <input type="email" size="40" name="email" placeholder="Email" required><br><br> 
     <textarea required rows="8" cols="41" name="comments" placeholder="Comments"> </textarea><br><br> 
     <input class="button" type="submit" name="submit" value="Send Query"> 
    </form> 
</section> 

我试过在页面的顶部分配焦点的元素但没有奏效:

function getfocus() { document.getElementById("mi").focus(); }

您能否提供一个解?

+4

删除'name'输入中的'autofocus'。 – forrestmid

+0

试过....没有工作。 – Trevor

+1

https://jsfiddle.net/n0kkdeb0/完美地工作。如果它确实不适合你,可能是由其他原因引起的。发布你的整个代码。 –

回答

0

从名称输入中删除自动对焦也适用于我。检查元素以查看它是否已被删除/清除缓存。

+0

好的,谢谢大家。我已经证明,有3种不同的浏览器,移除自动对焦可以解决这个问题。我以为在发布问题之前我曾尝试过,但可能不正确。 – Trevor