Sto verificando l'url per vedere se contiene o include un? in esso per controllare lo stato pop dell'hash nella finestra. Tutti gli altri browser non hanno un problema solo IE.IE11 - L'oggetto non supporta la proprietà o il metodo 'includes' - javascript window.location.hash
Il debugger mi dà questo errore quando provo a caricare in questo modo oggetto non supporta la proprietà o il metodo 'include'
ottengo alcun errore quando carica la pagina in tghrough il popstate
$(document).ready(function(e) {
if(window.location.hash) {
var hash;
if(window.location.hash.includes("?")) {
alert('I have a ?');
hash = window.location.hash.substring(window.location.hash.indexOf('#') + 0,window.location.hash.indexOf('?'));
}else {
hash = window.location.hash;
};
if (hash=="#DRS" || hash=="#DRP" || hash=="#DFFI" || hash=="#DCI" || hash=="#DCP" || hash=="#DRP" || hash=="#DRMA" || hash=="#EICS" || hash=="#ORG"){
$(hash+'Content').addClass('pageOn').removeClass('pageOff');
}else {
$('#homeContent').addClass('pageOn').removeClass('pageOff');
};
} else {
$('#homeContent').addClass('pageOn').removeClass('pageOff');
}
$(window).on('popstate', function() {
var hash;
if(window.location.hash.includes("?")) {
hash = window.location.hash.substring(window.location.hash.indexOf('#') + 0,window.location.hash.indexOf('?'));
}else {
hash = window.location.hash;
};
if (hash=="#DRS" || hash=="#DRP" || hash=="#DFFI" || hash=="#DCI" || hash=="#DCP" || hash=="#DRP" || hash=="#DRMA" || hash=="#EICS" || hash=="#ORG"){
$(this).navigate({target: $(hash+'Content')});
if(window.location.hash.includes("?")) {
}else{
location.href = location.href+'?';
}
}else {
$(this).navigate({target: $('#homeContent')});
};
});
});
Qual è il valore di 'window.location.hash' in Internet Explorer 11? – nils
TL; Risposta DR: usare .indexOf ('')> = 0 invece di .includes ('') – Andrew