ladybird/Tests/LibWeb/Text/data/iframe-popstate-event.html
Aliaksandr Kalenik 23d683cf6b LibWeb: Update document url after same-document back/forward navigation
Seems like a specification bug, but other browsers update url before
popstate event is fired and so should we.

Fixes back/forward navigation on GitHub.
2024-04-21 12:41:36 +02:00

11 lines
385 B
HTML

<script>
window.history.pushState({}, '', window.location.href + '#test');
window.addEventListener('popstate', (e) => {
const url = new URL(window.location.href);
const pathWithHash = url.pathname.split('/').pop() + url.hash;
parent.postMessage(`popstate event from iframe new_path=${pathWithHash}`, '*');
});
window.history.back();
</script>