Created
June 14, 2018 20:18
-
-
Save mindblender/c29ad4934c47e820302b3c52b7a95ca9 to your computer and use it in GitHub Desktop.
CAS Preserve Anchor tag in URL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function prepareSubmit(form) { | |
| // Extract the fragment from the browser's current location. | |
| if (self.document.location.hash.indexOf('%00')) { | |
| self.document.location.hash = self.document.location.hash.replace('%00', '{{casnull}}'); | |
| } | |
| var hash = decodeURIComponent(self.document.location.hash); | |
| if (hash.indexOf('{{casnull}}')) { | |
| hash = hash.replace('{{casnull}}', '%00'); | |
| self.document.location.hash = self.document.location.hash.replace('{{casnull}}', '%00'); | |
| } | |
| // The fragment value may not contain a leading # symbol | |
| if (hash && hash.indexOf("#") === -1) { | |
| hash = "#" + hash; | |
| } | |
| // Append the fragment to the current action so that it persists to the redirected URL. | |
| form.action = form.action + hash; | |
| return true; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment