Issue
I don't think my question needs much more context but the basic problem I'm facing is that I have a script running to hide the nav bar, simple stuff. I have a page that has very little content but it's enough to have a small scroll and due to this, the page looks ugly if a user scrolls.
I tried:
if(window.location.pathname == "/page.php") {
return;
} else {
//code...
}
But it's not working for some reason. The else
block is still running. My URL is something like localhost/foldername/page.php?data=something
I'm using xampp and no frameworks as I've just started learning Web Development last week so any solutions that do not include any frameworks is appreciated. I will learn frameworks, just not now
Solution
If the url is http://localhost/foldername/page.php?data=something
then the pathname will be:
/foldername/page.php
So try just checking for that filename
if(window.location.pathname.includes("/page.php")) {
//code...
}
Or use the full pathname
if(window.location.pathname === '/foldername/page.php)...
Answered By - charlietfl Answer Checked By - Katrina (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.