简体   繁体   中英

How do I prevent focus on form (at bottom of page) when page loads?

My page contains a form at the bottom. When the page loads the browser gives focus to the form, when what I want is for the top of page to be shown.

The form is:

<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>

I've tried assigning focus to an element at the top of the page but that hasn't worked:

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

Can you suggest a solution?

Removing autofocus from name input works for me too. Inspect element to see if it has been removed/Clear cache.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM