jquery - Check link variable with JavaScript -
take example, page follows:
with javascript, how can check if window's location contains ?page=about
?
this code have far, can't seem work.
$(document).ready(function(){ if ($(window.location:contains('?page=about')").length !== 0) { alert("currently on page"); } else { } });
please :)
thanks
use .indexof()
instead of contains
if ( window.location.href.indexof('?page=about') > -1)
window.location
contains location object .. href attribute holds url
Comments
Post a Comment