I have a link with a variable? Sid = .... being executed, but I want that if this variable exists it does not perform the function.
get the value of the variable and if it is false execute.
URL: https://example.com/?sid=2134912fhjkdhfsjdhf234829347wdjfsdf
function oldPrice() {
var url = window.location.search.replace("?", "");
var items = url.split("");
var array = {
'id': items[20]
}
var result = array.id;
if (window.location.href != "https://www.mysite.com.br/" || result == false) {
const spans = document.querySelectorAll(".old-price.sly-old-price.no-display");
for (let i = 0; i < spans.length; i++) {
const span = spans[i];
span.classList.add("forceview");
}
}
return null;
}
oldPrice();