Chrome auto page scrolling to select Multiple with selected option

Asked

Viewed 115 times

2

When using the attribute multiple, the page when loaded, scrolls to the last <select/> containing a option with the attribute selected:

Example in Jsfiddle

<p>No Google Chrome a página não fica aqui...</p>
<form style="padding-top:1000px;">
    <p>No Google Chrome desliza para aqui...</p>
    <select multiple="multiple">
        <option selected="selected">1</option>
        <option>2</option>
    </select>
</form>

form{
    padding-top:1000px;
}
<p>No Google Chrome a página não fica aqui...</p>
<form>
    <p>No Google Chrome desliza para aqui...</p>
    <select multiple="multiple">
        <option selected="selected">1</option>
        <option>2</option>
    </select>
</form>

This same problem is also reported for Chromium although the indication is that it only appears in some versions:

Question

How to get around this problem so that the website has the same behavior in all browsers?


Tests where the problem does not occur:

  • Chromium Version 37.0.2062.120 Built on Ubuntu 14.04, running on Linuxmint 17 (64-bit)
  • Mozilla firefox 32.0.3 for Linux Mint - Mint - 1.0
  • Internet Explorer 11 - Version 11.0.9600.17351 - Update 11.0.13 running on Windows 8.1

Successfully playing the bug:

  • Google Chrome - Version 38.0.2125.111 m running on Windows 8.1
  • Sorry to "resurrect" the question, I was reviewing some unanswered questions and I came across yours, I could not reproduce the problem, tell me it still occurs? (version 39) Another thing my Windows is x64, your Windows is on a virtual machine (probably x86)?

  • @Guilhermenascimento You did well, I have found a solution to overcome the problem, I will have to come up with an answer with it. As of today, I do not know if the problem still exists. I will give feedback as soon as possible on the subject.

1 answer

1

As of today, after updating Google Chrome browser to version "39.0.2171.95 m" running on Windows 8.1 64bit the problem is no longer verified.

Back then, to get around the bug present in the version indicated in the question and in others as seen in bug Reports also indicated in the question, in the end I applied the following workaround:

See example in Jsfiddle functional only in versions where the bug is noted

Javascript

// Quando o documento está pronto
document.addEventListener("DOMContentLoaded", function(event) { 

        // ... outras ações primeiro ...


        var isChrome = window.chrome;    // identifica se é o Google Chrome
        if (isChrome) {                  // se for
            window.scrollTo(0,0);        // força o scroll para o topo da janela
        }
});

jQuery

// Quando o documento está pronto
$(document).ready(function() {

    // ... outras ações primeiro ...


    var isChrome = window.chrome;    // identifica se é o Google Chrome
    if (isChrome) {                  // se for
        window.scrollTo(0,0);        // força o scroll para o topo da janela
    }
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.