Hi, i am creating a button to perform different functions depending on if it is in a subfolder or not.
I am splitting the pathname of whatever page i am on by ‘/’ and running a different function if the pathname.split(’/’).length is: , , or .
The problem is that on all the pages on my site whether they are:
are all giving me an array length of , which is preventing me from running an if statement for each length.
var host = window.location.host; var path = window.location.pathname; var sub = path.split('/'); var subL = sub.length; alert(subL);
does anyone have any insight on this? Thanks