Using Joomla to create my site. Let say my site is located at
I want to get this path in javascript on any page rendered on my site. The issue is, following internal sub menus and site's different settings, the path comes to be any one like these-
I have tried some solutions like-
var re = new RegExp(/^.*\//);
alert(re.exec(window.location.href));
It truncates the last node as index.php in case 1, also
var dummy = new Image;
dummy.src = '$';
alert(dummy.src.slice(0,-1));
does the same thing. So is there any way to get exact address where site is located using javascript only? Also the result must be generic for any site as if it is applied in any extension then that extension can be installed in any site with any level of directory structure.
I require this as I am using a js file which is internally registering another js file. So path for this, to be registered js has to be given in first js