Created
August 18, 2014 18:35
-
-
Save nileshk/8d4129b10cb2ddb933e8 to your computer and use it in GitHub Desktop.
Get current "base" URL (without the document portion or parameters)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get current URL without the document portion or parameters | |
// For example, if the URL is: | |
// http://hostname:8080/path/to/application/document.html?param1=1¶m2=2 | |
// baseUrl will be: | |
// http://hostname:8080/path/to/application/ | |
var baseUrl = [location.protocol, '//', location.host, location.pathname.split('/').slice(0, -1).join('/'), '/'].join(''); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment