Find root folder

17 Ⅴ 2010

I use this tiny snippet that uses jquery to find the root folder of my website.
It assumes jquery.js is included in the page.
It’s usefull for finding out where to post ajax stuff to (so you have a complete root).

For this website it would look in the header of the html for:
<script type="text/javascript" src=""></script>

// Get the source directory of this script
root = $('script[@src$=jquery.js]').attr('src').replace('js/jquery.js', '');
	root = root.replace('www.', '');