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: [1], [2], or [3].
The problem is that on all the pages on my site whether they are:
mysite.com/page
mysite.com/folder/page
mysite.com/folder/folder/page
are all giving me an array length of [2], 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