Small Javascript to count the level of sub directories
Hi there!
i was looking for a javascript code to get the level of the browser location with javascript. I could not find anything usefull therefor I’ve written a piece of code. I hope you find it usefull. This script will output the exact number of directories you are in.
ie.
var TheURL = location.href;
var CleanUp = TheURL.replace(/http:\/\/([0-9a-zA-Z._])*\//,"")
var TheDir = CleanUp.split("/")
var TheCount = TheDir.length-1
document.write(TheCount)
Leave a comment if you think this code was usefull.
Tags: Javascript























