- ...
(1-4), , HTML4 ( history.js http://domain.org/page/page#-http://domain.org/modalpage, ).
, :
onpopstate. , :
window.onpopstate = function(e) {
var State = e.state;
if (!State) {
$('#modal').modal('hide');
}
else {
var modalURL = State.URL.substring(State.URL.indexOf('?show=')+6);
openModal(appRoot+modalURL, State);
}
}
onpopstate , (, , ), URL-. URL- '? Show = relativeModalLink/', , . , , URL-, , ( ).
, , , , , , . , .
, - :
function openModal(modalLink, state) {
if (state === undefined) {
var shortLink = modalLink.substring(modalLink.indexOf(appRoot)+appRoot.length);
var stateLink = document.location.href.indexOf('?show=') === -1 ? document.location.href+'?show='+shortLink : document.location.href;
history.pushState({'type': 'modal','URL':stateLink},'',stateLink);
}
}
, , , "" .
, .
getcha: window.history.back() ( "" ). , , , ( onpopstate .modal('hide')). , "", "" (, , ...).
history.js, script . HTML5, , , HTML4 ( URL, ). history.js , "ajaxifying" .
, !