我正在制作一个在线商店,我需要制作一个按钮,该按钮应该包含指向新页面的链接,并且在从商店的所有页面永久消失之后。
到目前为止,我有这段代码:
<input class="button" value="Press to Register" type="submit" name="submit" tabIndex="8" onClick = "this.style.visibility= 'hidden'; window.open('/my-account/','_top')">
<style type="text/css">
.button {
font-family: Verdana, Arial, sans-serif;
display: inline-block;
background: #459300 url('../images/orange_bg.jpg') top left repeat-x;
border: 1px solid #459300 ;
padding: 5px 7px 5px 7px;
color: #fff;
font-size: 12px;
cursor: pointer;
}
.button:hover {
text-decoration: none;
}
.button:active {
padding: 5px 7px 5px 7px;
}
</style>
因此按钮现在消失,将我重新定位到新页面,但在新页面上我仍然可以看到它。
提前谢谢!!
答案 0 :(得分:0)
您需要创建cookie或LocalStorage
<input class="button" value="Press to Register" id="hideme" type="submit" name="submit" tabindex="8" onclick="this.style.visibility = 'hidden'; window.open('/my-account/', '_top'); localStorage.setItem('hideforever', 1);">
<script>
if (localStorage.getItem('hideforever') == 1) {
document.getElementById("hideme").style.visibility = "hidden";
}
</script>
<style type="text/css">
.button {
font-family: Verdana, Arial, sans-serif;
display: inline-block;
background: #459300 url('../images/orange_bg.jpg') top left repeat-x;
border: 1px solid #459300;
padding: 5px 7px 5px 7px;
color: #fff;
font-size: 12px;
cursor: pointer;
}
.button:hover {
text-decoration: none;
}
.button:active {
padding: 5px 7px 5px 7px;
}
</style>
答案 1 :(得分:0)
我看到你正在使用WordPress登录。您应该能够通过检测用户是否已登录来隐藏您的按钮,并在您拥有按钮的情况下创建if语句。像这样:
<?php
if ( !is_user_logged_in() ) {
?>
<input class="button" value="Press to Register" type="submit" name="submit" tabIndex="8" onClick = "this.style.visibility= 'hidden'; window.open('/my-account/','_top')">
<?php
}
?>