I have a problem with my website. On loading it scrolls automatically to the bottom.

It is because there is a contact form with focus on name. How can I remove this focus?



2 Answers 2


Change this line from the contact from

var contactForm = new VarienForm('contactFormNew', true);


var contactForm = new VarienForm('contactFormNew', false);

The second parameter means "focus on first field". That's why you get the down scroll.

  • Solve my issue scroll to bottom.
    – Sourav
    Sep 18, 2016 at 13:16

If you work for a company that outsources back end development, as I do, you might not be able to access the form template. In this case you won't be able to change the VarienForm function's arguments. (If you can change these arguments, as per the approved answer, you should.)

You can add the code (provided below) to the body of your affected page within a <script> tag.

To summarise, the code waits for the first time the focused element changes, then unblurs that element and resets the scroll to the top of the page. If nothing happens within ten seconds of the script running, it'll turn itself off. This is just a safeguard to prevent the script running forever in the event of an error.

    var lastActiveElement = document.activeElement;
    //time elapsed in MS
    var time = 0;
    //stop checking after 10 seconds
    var stopTime = 10000;
    //interval to check for changes
    var intervalTime = 20;

    function _Check_For_Form_Validation(){
        if ( document.activeElement != lastActiveElement ){
            document.documentElement.scrollTop = 0;
            clearInterval( interval );
        if ( time >= stopTime ){
            clearInterval( interval );

    var interval = setInterval( function(){
        time += intervalTime;
    }, intervalTime);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.