As in the question how to make the code given below change the URL in your browser after the request is made and after loading the content of the page? I don't know how to do it myself, I've been trying to do it for days.
If possible, how to make JS scripts loaded from a new page (after the request) work (innerHTML
does not interpret as a result of scripts).
document.addEventListener('click', function(event) {
if (event.target.tagName !== "A" || !event.target.href) return;
document.body.style.opacity = 0;
event.preventDefault();
document.body.addEventListener("transitionend", function() {
var res = new XMLHttpRequest();
res.addEventListener("load", function() {
if (res.status != 200) {
console.log(`Error ${res.status}: ${res.statusText}`);
} else {
document.querySelector('html').innerHTML =
this.response;
}
});
res.open("GET", event.target.href);
res.send();
});
});
If more clarification is needed, please comment below.