' uckulting typeError'仅在第一页上仅在桌面上的Chrome中加载。在第二或多个页面加载上工作。怎么了?
我有一个问题,只有在桌面上的Chrome中的第一页加载中存在。它在第二页或多个页面加载中在Chrome中起作用。它还可以在每个页面加载下在Chrome的移动设备上工作。
在大多数情况下,它在Safari和Firefox中正常工作。我在那里也遇到了以下错误,只有在第一页加载下,仅在桌面上,但是我无法在那里重现大约一整天。
有人知道发生了什么吗?
我唯一能想到的是触发我的重定向
函数。因为正如您在下面指示的第6个流程中看到的那样,在错误之后,该页面将重定向回到index.html。但是,只有当我的SessionStorage值之一是null
的值时,该功能才会触发,并且在浏览器控制台中可以看到,当我按下按钮进入下一页时,将正确设置这些值。
错误:
流量:
- 带有单独的index.js
- 登录页面是index.html,在选择几个下拉词时, ,3个值存储在SessionStorage
- 下一页中,称为:ander-quiz.html带有单独的normal-quiz.js
- sessionStorage的formal-quiz.html被检索到滤波数据阵列
- 中的loadquiz函数在过滤后的数组上运行,并将问题元素设置为对象的'egnerne' 属性
- '首页加载的
- ,仅在桌面上的Chrome中,上述错误发生,这会使浏览器返回index.html和SessiveStorage ,如果我再次尝试上述内容,它无需问题而没有问题。
线生成错误是我的位置。使用LoadQuiz函数将我的HTML中的问题元素的值设置为已过滤阵列中第一个对象的“英语”属性值。
代码(JS):
function redirect() {
if (selectedBook !== null) {
// do nothing
} else {
window.location = "<myURL>"
};
};
redirect();
function loadQuiz() {
const currentQuizData = quizArr[currentQuiz]; // currentQuiz is the question counter. It starts at 0 to get the first object, then increments by 1 after each question
questionEl.innerText = currentQuizData.english;
// line above is where the error is generated
counter.innerText = (currentQuiz + 1) + "/" + quizArr.length;
};
loadQuiz();
I have this problem that only exists on first page load in Chrome on desktop. It works in Chrome on the second or more page loads. It also works on mobile in Chrome on every page load.
It works fine in Safari and Firefox, MOST OF THE TIME. I have experienced the below error there as well, only on first page load, only on desktop, but I am not able to reproduce it there for about an entire day now.
Does anyone know what is going on?
The only thing I have been able to come up with is that somehow my redirect
function is triggered. Because as you can see in the flow indicated below at number 6, after the error, the page redirects back to index.html. However that function would only trigger if the value of one of my sessionStorage values is null
and I can see in the browser console that those values are set correctly when I press the button to go to the next page.
The error:
The flow:
- Landing page is index.html with separate index.js
- Upon selection of a few drop-downs, 3 values are stored in sessionStorage
- Next page is called: normal-quiz.html with separate normal-quiz.js
- Values from sessionStorage are retrieved to filter a data array
- The loadQuiz function runs on the filtered array and sets a question element value to an object's 'english' property
- On first page load, only in Chrome on desktop, the above error occurs which makes the browser return to index.html and sessionStorage is cleared
- If I try the above again, it works without a problem
The line generating the error is where I use the loadQuiz function to set the question element's value in my html to the 'english' property value of the first object in the filtered array.
The code (js):
function redirect() {
if (selectedBook !== null) {
// do nothing
} else {
window.location = "<myURL>"
};
};
redirect();
function loadQuiz() {
const currentQuizData = quizArr[currentQuiz]; // currentQuiz is the question counter. It starts at 0 to get the first object, then increments by 1 after each question
questionEl.innerText = currentQuizData.english;
// line above is where the error is generated
counter.innerText = (currentQuiz + 1) + "/" + quizArr.length;
};
loadQuiz();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论