How do I preserve uri fragment in safari upon redirect?

前端 未结 1 821
旧时难觅i
旧时难觅i 2020-12-14 23:05

My gwt / gae application utilizes activities and places. In order to create asynchronous processes (such as resetting a password or verifying ownership of an email address)

相关标签:
1条回答
  • 2020-12-14 23:46

    Just serve a redirect page (200) that refreshes the window.location upon load and injects the hash fragment.

    <!DOCTYPE html>
    <meta charset="utf-8">
    <html>
    <body>
    <script>
        var hash = (location.href.split("#")[1] || null);
        var pathField = "{{redirectUri}}";
        if (hash) {
            if (pathField.indexOf("#") == -1) {
                pathField = pathField + "#" + hash;
            }
        }
        window.location = pathField;
    </script>
    </body>
    </html>
    

    That way, it works with every browser (at least browsers that support javascript). {{redirectUri}} is the URL you want to redirect to. If it contains a fragment already, it won't be overwritten.

    0 讨论(0)
提交回复
热议问题