[Webkit-unassigned] [Bug 212839] history.replaceState(..) results in title being removed from history entry

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Sat Jun 6 11:45:57 PDT 2020


https://bugs.webkit.org/show_bug.cgi?id=212839

--- Comment #6 from Jimmy Thomsen <jimmy at codemagic.dk> ---
I'm sorry. It seems that I by accident attached the wrong version of test2.html.
My intention was actually to have the title argument set to an empty string for both pushState and replaceState.

Never the less, it sure does work if the title argument is provided for both functions, and I now realize that contrary to all other browsers, Safari/WebKit uses the title argument, which is why it works in all other browsers except Safari.

Working version of test2.html:


<!DOCTYPE html>
<html>
<head>
        <title>Front page</title>
</head>
<body>

        <!-- Menu - navigation -->
        <a href="javascript:window.nav('frontpage');">Front page</a> | <a href="javascript:window.nav('about');">About</a> | <a href="javascript:window.nav('contact');">Contact us</a>

        <script>
                window.nav = function(pageId)
                {
                        var page = document.querySelector("#" + pageId);

                        if (page)
                        {
                                // Hide page currently visible
                                (window.curPage || document.querySelector("#frontpage")).style.display = "none";
                                window.curPage = page;

                                // Add navigatedAway property to page's current state. Safari bug:
                                // History entry will now lose its title, causing the back button
                                // pulldown menu to only reveal URLs, rather than document titles.
                                var changedState = history.state || {};
                                changedState.navigatedAway = new Date();
                                history.replaceState(changedState, document.title, location.href);

                                // "Navigate" to new page (update URL and display page)
                                history.pushState({}, page.title, pageId);
                                page.style.display = "block";
                                document.title = page.title;
                        }
                }
        </script>

        <!-- Website content - pages -->
        <div id="content" style="border: 1px solid silver; margin: 1em; padding: 1em;">

                <!-- Front page -->
                <div id="frontpage" title="Front page" style="display: block">
                        Welcome to the front page
                </div>

                <!-- About page -->
                <div id="about" title="About us" style="display: none">
                        So, our company is all about...
                </div>

                <!-- Contact page -->
                <div id="contact" title="Contact us" style="display: none">
                        Please fill out the contact form below to reach us..<br><br>

                        Your name<br>
                        <input><br><br>

                        Your e-mail address<br>
                        <input><br><br>

                        <button>Send</button>
                </div>

        </div>

</body>
</html>

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20200606/9ffcb25a/attachment.htm>


More information about the webkit-unassigned mailing list