<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#imgleft {
position: absolute;
}
html,
body {
/* height: 100%; */
height: 3000px;
}
</style>
</head>
<body>
<div id="imgleft">
KKKKKKKKKKKKKKKKKK
</div>
</body>
<script type="text/javascript">
var obj = document.getElementById("imgleft");
var ggRoll = {
roll: obj,
speed: 10,
statusX: document.documentElement.clientWidth - document.body.clientWidth,
statusY: document.documentElement.clientHeight - document.body.clientHeight,
x: 200,
y: 400,
// winW: document.body.clientWidth - obj.offsetWidth * 2,
// winH: document.body.clientHeight - obj.offsetHeight,
winW: window.innerWidth - obj.offsetWidth * 2,
winH: window.innerHeight - obj.offsetHeight,
Go: function () {
console.log(this.roll);
this.roll.style.left = this.x + 'px';
this.roll.style.top = this.y + 'px';
this.x = this.x + (this.statusX ? -10 : 10);
if (this.x < 0) {
this.statusX = 0;
}
if (this.x > this.winW) {
this.statusX = 1;
}
this.y = this.y + (this.statusY ? -10 : 10);
if (this.y < 0) {
this.statusY = 0;
}
if (this.y > this.winH) {
this.statusY = 1;
}
}
}
var intervaly = setInterval(function () {
ggRoll.Go()
}, ggRoll.speed);
ggRoll.roll.onmouseover = function () {
clearInterval(intervaly);
};
ggRoll.roll.onmouseout = function () {
intervaly = setInterval(function () {
ggRoll.Go()
}, ggRoll.speed);
};
function closediv() {
clearInterval(intervaly);
obj.style.display = "none";
obj.parentNode.removeChild(obj);
}
</script>
</html>
在谷歌浏览器中Response中set-cookie无效,但是使用火狐没有问题:https://www.jianshu.com/p/77c769692033(原链接)
Set-Cookie里面有感叹号解决方案:
Set-Cookie: JSESSIONID=F5301C0990942B773A06A9A9C96226DA; Path=/contingency; HttpOnly
解决方法:
1.在浏览器地址中输入 chrome://flags
2.搜索框中输入 SameSite by default cookies
3。操作下拉框选择 Disabled 属性