I am working with a SAAS CMS and there is no variable for me to grab if I am on a section landing page or a paginated page. I need to be able to hide a div if I am on a page that contains "?page=" in the URL. Is there any successful way to do this with jQuery? I have tried several solutions offered up on SO, but none of the solutions I have tried works for my situation.
Just adding another note here. URLs out of the CMS that need to be targeted are looking like this foo?page= or bar?page= so I am just trying to detect the ?page= portion and hide the div if that is present. Thanks!
Have tried:
$(document).ready( function() {
if (/\/?page=\//.test(window.location)) {
$('#collection-description').hide();
}
});
and
$(document).ready( function() {
if ($('a[href*=page']).size() > 0) {
$('#collection-description').hide();
}
});
Any other directions to try would be awesome. Thanks!
Try taking a look at these pages:
Get current URL in JavaScript?
https://developer.mozilla.org/en/DOM/window.location
You should be able to to use window.location.search to break out the elements you need. All major browsers should support this, though I haven’t tested them myself.
So you could try something like this for the detection: