我在Internet Explorer 11中收到错误
“无法获取未定义或空引用的属性'长度” 线
if (window.localStorage.length !== 0)
它在chrome和Firefox上运行良好,不确定是什么导致它
<script>
function initialize() {
// test to see if brouser supports storeage api
var bSupportsLocal = (('localStorage' in window) && window.localStorage !== null );
if (!bSupportsLocal) {
document.getElementById('infoform').innerHTML = "<p> Sorry, This browser does not suport local storage. </p>";
return;
}
if (window.localStorage.length !== 0) {
document.getElementById('firstName').value = window.localStorage.getItem('firstName');
$.mobile.navigate("#benefits-facts");
}
}
function storeLocalContent(fName) {
window.localStorage.setItem('firstName', fName);
}
function clearLocalContent(strToStore) {
window.localStorage.clear();
}
window.onload = initialize;
</script>
答案 0 :(得分:1)
我认为IE @interface ViewController (){
NSString *phone;
}
@end
-(void)example
{
[self.varble ^block
{
phone=@"abc";// a retain cycle?
}];
}
最初是未定义的。您正在检查C:\Users\Tom\Anaconda>python
Python 2.7.6 |Anaconda 1.9.2 (64-bit)| (default, Nov 11 2013, 10:49:15) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
>>>
中的window.localStorage
,而不是localStorage
。所以window
设置为true。它正在执行null
语句。 Undefined.length导致错误。
这是代码
bSupportLocal
如果localStorage有一些值,它会分配给bSupportsLocal,否则会为它分配空字符串。