Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

217
Vistas
scrollIntoView() ancestor frame scrolling in Firefox but not Chrome

It seems Chrome and Firefox have two different interpretations of scrollIntoView() when it comes to iframes. In Chrome, the scrolling only applies to elements until a position:fixed ancestor element is found, whether it is in the iframe or parent frame. But in Firefox, it is not just any ancestor that has position:fixed; there seems to need to be an unscrollable ancestor element in the parent frame also, otherwise the parent frame will still scroll.

I want to prevent Firefox from scrolling the parent frame in this case. So far the only solution I have found is making an element in the parent frame be position:fixed, but as you can imagine that will ruin the parent frame's layout if you don't want a fixed element and want the page to flow (eg, if the iframe is embedded within a long blog post).

Note that I do NOT have control over the iframe (it is cross domain also), otherwise I could just switch scrollIntoView() with scrollTo().

Here is a concrete example you can test:

<html>
<head>
<title>Parent frame</title>
<style>
html { scroll-behavior:smooth; }
</style>
</head>
<body>
<iframe src="iframe.html" style="height:200px;"></iframe>
<div style="height:10000px;">parent</div>
</body>
</html>
<html>
<head>
<title>Child frame</title>
<style>
</style>
<script>
setTimeout(function() {
    var bottom = document.getElementById("bottom");
    bottom.scrollIntoView();
}, 2000);
</script>
</head>
<body>
<div id="someParent" style="height:200px;position:fixed;overflow:scroll;">
<div style="height:5000px;">iframe</div>
<div id="bottom" style="background-color:red;">bottom</div>
</div>
</body>
</html>
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda