jQuery/JS: Get current URL parent directory

javascript, jquery, url

Solution

var myURL = "http://www.site.com/example/index.html";
var myDir = myURL.substring( 0, myURL.lastIndexOf( "/" ) + 1);

Problem

From: http://www.site.com/example/index.html How can I get just: http://www.site.com/example/ And storing it into a variable using Javascript and how using jQuery also. Thanks in advance.

Original source