Estoy tratando de insertar un evento de desplazamiento en un IFRAME en código HTML, para activar un evento cuando el usuario haya desplazado el sitio/documento hasta el final.
Encontré varias sugerencias sobre "stackoverflow" e intenté usarlas, pero por alguna razón, el código que inserté no funciona.
este es un ejemplo de mi código:
<!DOCTYPE html> <html> <body> <p>Click the button to change the value of the src attribute in the iframe.</p> <input type= "url" id="hi" value = "hello" onchange="myFunction2()"> <button onclick="document.getElementById('myFrame').src = document.getElementById('hi').value;" id=getFile >Upload File</button></br></br> <iframe id="myFrame" src="https://agilepoint.com/"></iframe> <p id="demo"></p> <script> window.onscroll = function(ev) { var Frame = document.getElementById("myFrame"); if ((Frame.innerHeight + Frame.scrollY) >= document.body.offsetHeight) { alert("you're at the bottom of the page"); } }; </script> </body> </html>También probé esto:
<!DOCTYPE html> <html> <body> <p>Click the button to change the value of the src attribute in the iframe.</p> <input type= "url" id="hi" value = "hello" onchange="myFunction2()"> <button onclick="document.getElementById('myFrame').src = document.getElementById('hi').value;" id=getFile >Upload File</button></br></br> <iframe id="myFrame" src="https://agilepoint.com/"></iframe> <p id="demo"></p> <script> document.getElementById("myFrame").onscroll = function(ev) { var Frame = document.getElementById("myFrame"); if ((Frame.innerHeight + Frame.scrollY) >= document.body.offsetHeight) { alert("you're at the bottom of the page"); } }; </script> </body> </html>No funcionó. Agradecería la ayuda. ¡Gracias!