Skip to content

Instantly share code, notes, and snippets.

@mindblender
Created June 14, 2018 20:18
Show Gist options
  • Select an option

  • Save mindblender/c29ad4934c47e820302b3c52b7a95ca9 to your computer and use it in GitHub Desktop.

Select an option

Save mindblender/c29ad4934c47e820302b3c52b7a95ca9 to your computer and use it in GitHub Desktop.
CAS Preserve Anchor tag in URL
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