Jump to content

Links with target set to iframe


setun-90

Recommended Posts

Hello,

 

I have a SPA consisting basically of an <iframe> with a navigation pane containing (a lot of) <a>s to the pages on the website organized in a hierarchical fashion. When a user clicks on a link in the navigation pane, the page shows up in the iframe.

Indeed, there is a <base target="$iframeName"> in the head of the page constituting the SPA.

 

Now, since the links in the navigation pane all have their target set to the iframe, they don't affect the url, but they do add an entry to the history. If the user presses the back button, the url of the iframe doesn't change.

 

Is there any way to catch the url, incorporate it into the history and direct it at the iframe without having to maintain a pushdown stack of visited urls?

Link to comment
Share on other sites

This is how you can modify the history:

 

https://developer.mozilla.org/en-US/docs/Web/API/History_API

 

You've found one of the reasons why people don't use iframes for things like that. Another one is that people can't really link to a specific page unless you want to add more code to detect if the page is not in a frame and, if not, redirect to the frame to get the navigation and automatically load whatever page they were looking at.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...