Is there a way to ask JavaScript what web page is currently loaded?
Example:
if(page loaded == index.php){
do something
}
else if(page loaded == contact.php){
do something else
}
Thanks
var sPath = window.location.pathname;
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
if(sPage == "index.php"){
do something
}
else if(sPage == "contact.php"){
do something else
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With