* Change the data of the current history for HTML4 browsers * * @param {Object} state * @param {string} [url] * @param {Boolean} [replace] * @param {string} [lastURLValue] * @return void
(state, url, replace, lastURLValue)
| 847 | * @return void |
| 848 | */ |
| 849 | function changeState(state, url, replace, lastURLValue) { |
| 850 | if (!isSupportHistoryAPI) { |
| 851 | // if not used implementation history.location |
| 852 | if (isUsedHistoryLocationFlag === 0) isUsedHistoryLocationFlag = 2; |
| 853 | // normalization url |
| 854 | var urlObject = parseURL(url, isUsedHistoryLocationFlag === 2 && ('' + url).indexOf("#") !== -1); |
| 855 | // if current url not equal new url |
| 856 | if (urlObject._relative !== parseURL()._relative) { |
| 857 | // if empty lastURLValue to skip hash change event |
| 858 | lastURL = lastURLValue; |
| 859 | if (replace) { |
| 860 | // only replace hash, not store to history |
| 861 | windowLocation.replace("#" + urlObject._special); |
| 862 | } else { |
| 863 | // change hash and add new record to history |
| 864 | windowLocation.hash = urlObject._special; |
| 865 | } |
| 866 | } |
| 867 | } else { |
| 868 | lastURL = windowLocation.href; |
| 869 | } |
| 870 | if (!isSupportStateObjectInHistory && state) { |
| 871 | stateStorage[windowLocation.href] = state; |
| 872 | } |
| 873 | isFireInitialState = false; |
| 874 | } |
| 875 | |
| 876 | /** |
| 877 | * Event handler function changes the hash in the address bar |