Javascript开始在iPhone和IE上不起作用



我仅在移动Safari和IE上收到以下错误。

TypeError: undefined is not a function

有问题的代码是:

if(window.location.origin.startsWith(shopAddress + "/account/login")  && 
sessionStorage.getItem('loggedIn') == "true")

这在Chrome和Firefox中运行良好。知道为什么Safari和IE不喜欢它吗?

您可以添加以下填充物

if(!String.prototype.startsWith) {
String.prototype.startsWith = function(searchString, position){
return this.substr(position || 0, searchString.length) === searchString;
};
}

最新更新