我不知道为什么,但我对这段代码有问题。横幅显示在每个页面上,尽管它指定了属性 $(location).attr('href') 您可以帮助我吗?:
<div id="bottombar">
<div class="bottom-content">
<a href="http://www.cliente.org/" target="_blank"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/banner/bottom-logo.png" alt="player-logo" /></a>
<a href="http://www.cliente.org/" target="_blank"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/banner/bottom-txt.png" alt="player-slogan" /></a>
<img src="<?php bloginfo('stylesheet_directory'); ?>/images/banner/bottom-download.png" alt="player-download" />
</div>
<div id="bottombarClose"><p>Chiudi</p></div>
<script type="text/javascript"">
$(document).ready(function() {
var currentUrl = $(location).attr('href');
if(currentUrl == 'http://www.esempio.net/')
$('#bottombar').show();
$("#bottombarClose").click(function() {
$('#bottombar').hide();
});
});
</script>
</div>
CSS代码:
div#bottombar {
background-image: url(images/banner/player-bg3.png);
background-repeat: repeat-x;
bottom: 0;
color: #FFFFFF;
font-family: Arial,Helvetica,sans-serif;
height: 100px;
left: 0;
margin: 0;
position: fixed !important;
width: 100%;
z-index: 99999;
display:none;
}
.bottom-content {
bottom: 0;
height: 97px;
left: 50%;
margin-left: -495px;
position: absolute;
width: 960px;
z-index: 10;
}
#bottombarClose {
cursor: pointer;
float: right;
padding: 55px 10px 0 0;
}
你不是说只是location.href
?
这是假设你正在谈论window.location https://developer.mozilla.org/en/DOM/window.location而不是别的东西。
返回一个 Location 对象,其中
包含有关 URL 的信息
该文件并提供了方法
更改该 URL。您还可以分配
到此属性来加载另一个 URL。
地点是不是 dom 中的元素因此 jQuery 无法选择它。
所以你的代码会像这样:
var currentUrl = window.location.href;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)