IE11 - Object doesn't support property or method 'includes' - javascript window.location.hash -
i checking url see if contains or includes ? in control hash pop state in window. other browsers aren't having issue ie.
the debugger gives me error when try load in way object doesn't support property or method 'includes'
i no error when load page in tghrough popstate
$(document).ready(function(e) { if(window.location.hash) { var hash; if(window.location.hash.includes("?")) { alert('i have ?'); 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')}); }; }); });
according mdn reference page, includes
not supported on internet explorer. simplest alternative use indexof
, this:
if(window.location.hash.indexof("?") >= 0) { ... }
Comments
Post a Comment