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

Proposal: Add an isolatehistory attribute to iframes #8773

Closed
brandonmcconnell opened this issue Jan 23, 2023 · 2 comments
Closed

Proposal: Add an isolatehistory attribute to iframes #8773

brandonmcconnell opened this issue Jan 23, 2023 · 2 comments

Comments

@brandonmcconnell
Copy link

brandonmcconnell commented Jan 23, 2023

TL;DR

I propose adding an attribute to iframes such as isolatehistory to support isolating their history apart from the browser's history, so they can maintain their own history and not add entries to the browser's history.

As its stands now, there appears to be no viable workaround for this, so if you use an iframed experience—CodePen is one example among thousands like it—or anything like that which does history routing, you'll have to click the browser's back button repeatedly to get out of the page since the iframe polluted the history.

<iframe isolatehistory src="..."></iframe>

iframes using isolatehistory would also need their own instance of the History API so they can manage their history effectively with the same API, but apart from the containing/parent window.

Full explainer

Problem

Currently, when using iframes for experiences such as codepen or other history routing, the iframe adds entries to the browser's history. This can cause confusion and inconvenience for users, as they are forced to repeatedly click the browser's back button in order to exit the page.

Research

Upon researching potential workarounds for this issue, it was found that there does not appear to be a truly effective solution. Attempts to use JavaScript to manipulate the browser's history or prevent the iframe from adding entries to the history have proven to be unreliable and inconsistent.

Solution

In order to truly solve this problem, I propose the addition of an isolatehistory attribute to iframes. This attribute would allow for the iframe to maintain its own history, separate from the browser's history. This would eliminate the problem of confusing and inconvenient history entries, and provide a more seamless user experience.

<iframe isolatehistory src="..."></iframe>

iframes using isolatehistory would also need their own instance of the History API so they can manage their history effectively with the same API, but apart from the containing/parent window.

Conclusion

The addition of an isolatehistory attribute to iframes would greatly improve the user experience and eliminate confusion and inconvenience caused by iframe history entries being polluted into the containing/parent window's history. It is a simple and effective solution that would greatly benefit those who use iframes for embedded experiences with their own navigation or routing making use of the History API.

As this change is linked to a specific attribute and would not change anything by default when the attribute is omitted, there are no breaking changes.

@whatwg whatwg deleted a comment from omkarpawar2001 Jan 24, 2023
@domenic
Copy link
Member

domenic commented Jan 24, 2023

Duplicate of #6501; let's consolidate discussions there!

@domenic domenic closed this as completed Jan 24, 2023
@brandonmcconnell
Copy link
Author

@domenic Thanks!

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