mirror of
https://github.com/Mottie/tablesorter.git
synced 2025-01-12 15:24:21 +00:00
Prevent sort2Hash from adding extraneous entries to browser history
Use `window.location.replace` to update the browser URL only, rather than `window.location.hash`, which modifies the browser history.
This commit is contained in:
parent
86e2b7c355
commit
6fe2cdf810
@ -225,8 +225,19 @@
|
||||
hash = s2h.cleanHash( c, wo, component, hash );
|
||||
str += value;
|
||||
});
|
||||
// add updated hash
|
||||
window.location.hash = ( ( window.location.hash || '' ).replace( '#', '' ).length ? hash : wo.sort2Hash_hash ) + str;
|
||||
|
||||
// Combine new hash with any existing hashes
|
||||
var hashChar = c.widgetOptions.sort2Hash_hash;
|
||||
var newHash = ( ( window.location.hash || '' ).replace( hashChar, '' ).length ? hash : wo.sort2Hash_hash ) + str;
|
||||
var baseUrl = window.location.href.split(hashChar)[0];
|
||||
// Ensure that there is a leading hash character
|
||||
var firstChar = newHash[0];
|
||||
if (firstChar != hashChar) {
|
||||
newHash = hashChar + newHash;
|
||||
}
|
||||
|
||||
// Update URL in browser
|
||||
window.location.replace(baseUrl + newHash);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user