I have the following url modification script
var path = window.location.href
path=path.replace(/&/g, "&");
window.location.href=path;
The page keeps reloading... What should I do to make the page reload only once?
CodePudding user response:
where did you add window.location.href = path ? directly in the script element of the page ? if so, of course it should reload, as the navigator executes the script code each time it loads. Anyways, you need to upload the whole code, so we can help you.
CodePudding user response:
You should modify your script so window.location.href=path; is only called if & is detected
something like:
const path = window.location.href
if (path.includes("&")) {
window.location.href=path.replace(/&/g, "&");
}
