0
我将我的数组填充到checklistRequest.js中,我想在包含js代码的Termine_1s.html文件中访问它。我可以访问它,但是当我想遍历它时,它只给出了单个数字而不是字符串。在另一个js文件中访问js数组
我该如何解决这个问题?
checklistRequest.js
//Calls the checkbox values
function alertFunction()
{
//Retrieve the object from storage
var retrievedObject = localStorage.getItem('checkboxArray');
console.log('retrievedObject: ', JSON.parse(retrievedObject));
return retrievedObject;
}
Termine_1s.html
//Checks if title was checked already
var checklistRequest = alertFunction();
var titleAccepted = true;
for (var a = 0; a < checklistRequest.length; a++)//Iterates through whole array
{
if(title != checklistRequest[i] && titleAccepted == true)//Stops if false
{
titleAccepted = true;
}
else
{
titleAccepted = false;
}
}
谢谢,解决了它。 :) – Fuby