Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Chrome重新加载页面的方式与预期不同_Javascript_Html_Css - Fatal编程技术网

Javascript Chrome重新加载页面的方式与预期不同

Javascript Chrome重新加载页面的方式与预期不同,javascript,html,css,Javascript,Html,Css,我有一个带有两个“空格”的简单html页面 还有一些js代码在这些空间之间切换 let arrowLeft=document.querySelector(“.arrowLeft”); 设arrowRight=document.querySelector(“.arrowRight”); 箭头左键。addEventListener(“单击”,函数(){ document.body.classList.add(“右”); }) arrowRight.addEventListener(“单击”,函数

我有一个带有两个“空格”的简单html页面


还有一些js代码在这些空间之间切换

let arrowLeft=document.querySelector(“.arrowLeft”);
设arrowRight=document.querySelector(“.arrowRight”);
箭头左键。addEventListener(“单击”,函数(){
document.body.classList.add(“右”);
})
arrowRight.addEventListener(“单击”,函数(){
document.body.classList.remove(“右”)
})
css文件如下所示:

正文{
宽度:200vw;
位置:绝对位置;
溢出x:隐藏;
}
身体,对{
左:-100vw;
}
.space1{
左:0px;
宽度:100vw;
高度:100vh;
背景颜色:蓝色;
位置:绝对位置;
}
.空间2{
左:100vw;
宽度:100vw;
高度:100vh;
背景色:红色;
位置:绝对位置;
}
在chrome中,如果我在space2中重新加载页面,而不是返回原始状态,它会重新加载回space2,但由于类“.right”未应用于主体,返回space1的箭头不起作用


这个问题只发生在chrome中,即使我删除了缓存,它也会持续存在。我尝试应用该类并立即将其删除,但没有效果。

奇怪。。。我用同样的结果尝试了你的代码,chrome中的一个bug?Chrome并没有在重新加载时将类添加到body中,但其行为就像该类处于活动状态一样…奇怪。。。我用同样的结果尝试了你的代码,chrome中的一个bug?Chrome不会在重新加载时将该类添加到body中,但其行为就像该类处于活动状态一样。。。