I do not know why but I have problems with this code. The banner is displayed on every page although it has specified the attribute $(location).attr('href') you can help me?:
<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 Code:
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;
}
Don't you mean just location.href
?
This is assuming you are talking about window.location
and not something else.
Returns a Location object, which contains information about the URL of the document and provides methods for changing that URL. You can also assign to this property to load another URL.
Location is not an element in the dom thus jQuery can not select it.
So your code would be like so:
var currentUrl = window.location.href;
location
is not a DOM Element, it is a Location object.
You are trying to create a jQuery object from it, but it does not make sense.
Use this instead:
var currentUrl = window.location.href;
Try this
var currentUrl = window.location.href;
Try using var currentUrl = window.location.href
instead. This will return the location of the current page.
Instead of
$(location).attr('href');
use
currentUrl = location;
ok, I made the change in this way, but did not seem to work:
$(document).ready(function() {
var currentUrl = window.location.href;
if(currentUrl == 'http://streamingdb.net/')
$('#bottombar').show();
$("#bottombarClose").click(function() {
$('#bottombar').hide();
});
});
then I added a "display:none" to div#Bottombar and everything works. Thanks to all of your time.
精彩评论