我正在制作一个在线商店,我需要制作一个按钮,其中应该包括一个指向新页面的链接,然后从商店的所有页面中永远消失。
到目前为止,我有这个代码:
<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>
所以按钮现在消失了,将我重新定位到一个新页面上,但在新页面上我仍然可以看到它
提前感谢!!
我看到你正在使用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
}
?>
您需要创建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>