iframes hijacking anchor links
-
I’m using the Page Scroll to ID plugin on a WordPress site in Avada and have an issue where anchor scrolling on page load gets overridden by an embedded iframe.
Setup:
- Multiple anchor sections on the page set with standard
idattributes via the theme. - The page includes an embedded booking widget loaded via a script that inserts an iframe.
- Anchor links use the standard format, for example:
mysite.com/page/#section-anchor - Plugin settings:
- Page load scrolling enabled
- “Prevent other scripts from handling plugin’s links” enabled
- Default link selector used
Problem:
When visiting a URL with an anchor, the page initially scrolls to the correct section. However, once the iframe finishes loading, it causes the page to scroll back up, overriding the intended scroll position.
This issue occurs for anchors located below or near the iframe. What’s even more frustrating is that it works in the first instance but not if you try again – as in it’s unpredictable
What I’ve tried:
- Adjusting scroll offset
- Disabling other plugins and scripts
- Using
[ps2id]shortcodes - Custom JavaScript to delay or repeat the scroll
- Observing the iframe load with MutationObserver
- Clearing all caches
None of these reliably fix the problem. The iframe appears to shift layout or trigger scroll behavior late in the load process.
Question:
Is there a way for Page Scroll to ID to reapply or delay the scroll until after all layout shifts (including iframe loading) are complete? Or is there a recommended method to handle deep linking anchors on pages with embedded iframes?
I would appreciate any guidance.
The page I need help with: [log in to see the link]
- Multiple anchor sections on the page set with standard
The topic ‘iframes hijacking anchor links’ is closed to new replies.