davidjbradshaw / iframe-resizer

Keep iFrames sized to their content.
https://iframe-resizer.com
Other
6.67k stars 981 forks source link

Site Auto-scrolls to Contact Form #1347

Open markjamesm opened 5 hours ago

markjamesm commented 5 hours ago

Describe the bug When I load my website with the iFrame-Resizer, sometimes it auto-scrolls to the contact form at the bottom of the page.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://mayahtt.com
  2. The page should auto-scroll to the contact form, but the issue happens intermittently making it difficult to debug.

Expected behavior The page loads normally and only scrolls to the bottom when the URL contains the anchor link (https://mayahtt.com#contact)

Desktop (please complete the following information):

Additional context This seems to happen on any page containing a contact form but intermittently.

davidjbradshaw commented 3 hours ago

So the issue is that you want it to scroll, but sometime it doesn’t? The issue is going to be that the anchor you want to scroll to hasn’t loaded when you make the call to scroll.

I would try adding the defer attribute to the script tag you use to load in the child page JS file. So that things don’t start triggering until everything has fully loaded.

markjamesm commented 3 hours ago

The issue is that when a user lands on a page, it scrolls automatically when it shouldn't. The only time it should scroll is if a user clicks on a button with an anchor link, or lands on the page with an anchor link in the URL.

davidjbradshaw commented 2 hours ago

Then I don’t think this is an issue with iframe-resizer. It won’t scroll the page unless you request it to do so.

If you can recreated the bug with a simple example I can take more of a look, but I don’t have much to go on here.