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?:<
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;
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.
Instead of
$(location).attr('href');
use
currentUrl = location;
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;
Try this
var currentUrl = window.location.href;
Try using var currentUrl = window.location.href
instead. This will return the location of the current page.