mp13
1
Hi,
I am having problems linking to an anchor in an Iframe and I have not found any solutions yet that worked for me.
So this is my case:
All of this happens in the same domain.
(Page A) I have a page with content and an anchor
(Page B) Then I have a page with an Iframe of Page A
(Page C) And lastly a page where I have to link to the anchor in the Iframe
Does any of you tried this before or knows how his can be done with javascript?
Regards
Marcelo
m3g4p0p
2
Yes, you can set the location.hash
of the iframe like you can with the main window:
const iframe = window.frames['my-iframe']
iframe.contentWindow.addEventListener('load', function () {
this.hash = '#some-target'
})
When you link to that page you might pass the iframe-hash in a query string, like say
example.com/page-c.html?iframehash=%23some-target
then read that value in the JS and set the hash as shown above.
system
Closed
4
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.