我找到了我的博客的代码:
<script type="text/javascript">
document.body.onclick= function(){ window.open('My site', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=950, height=650, left = 300, top = 50'); }
</script>
但由于我对JS一无所知,因此我无法对其进行过多编辑。
答案 0 :(得分:2)
在弹出窗口显示之前检查localStorage
项目,当您显示它时,设置localStorage
项目。由于这在SO沙箱中不起作用,因此这是一个codepen https://codepen.io/mcoker/pen/PjqQqw
document.body.onclick = function() {
if (!localStorage.popup) {
localStorage.popup = 1;
window.open(
"My site",
"poppage",
"toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=950, height=650, left = 300, top = 50"
);
}
};
body {
min-height: 100vh;
}
答案 1 :(得分:0)
document.body.onclick= function(){ window.open('My site', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=950, height=650, left = 300, top = 50');document.body.onclick=function(){} }
点击一次
后重置onclick属性答案 2 :(得分:0)
使用Cookie https://jsfiddle.net/arvinddhakad/bq8f241a/
document.body.onclick = function() {
isPopup = document.cookie.replace(/(?:(?:^|.*;\s*)popup\s*\=\s*([^;]*).*$)|^.*$/, "$1") || false;
if (!isPopup) {
window.open('My site', 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=950, height=650, left = 300, top = 50');
document.cookie = "popup=true";
}
}