Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Back button not working with inPageLinks with workaround #1286

Closed
kevinkaske opened this issue Jul 5, 2024 · 2 comments
Closed

Back button not working with inPageLinks with workaround #1286

kevinkaske opened this issue Jul 5, 2024 · 2 comments

Comments

@kevinkaske
Copy link

When enabling inPageLinks during initialization, the anchor links work but the back button takes you to the previous page (the page in your history before the page that contains the iframe)

Expected behavior:
Take you to the previous spot on the parent page where the link was clicked.

Workaround:
I added the following to the child page to add the hash to the parent page history. I also added the class "samepagelink" to make assigning the javascript easier. This adds the same hash from the child page link to the parent page history.

    document.addEventListener("DOMContentLoaded", function() {    	
        var elements = document.getElementsByClassName("samepagelink");
        
        Array.from(elements).forEach(function (anchor) {
            anchor.addEventListener("click", function (event) {
                window.parent.location.hash = anchor.hash;
            });
        });
    });
@davidjbradshaw
Copy link
Owner

Interesting idea. Will give it some though on how to integrate it to the main code base.

@davidjbradshaw
Copy link
Owner

This was a one line fix that should have been there from the start. Thanks for the idea. It will be included in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants