JavaScript erhalten Sie Hostname von der aktuellen URL
var host = window.location.protocol + "//" + window.location.host;
Handsome Hawk
var host = window.location.protocol + "//" + window.location.host;
url = "http://www.example.com/path/to/somwhere";
urlParts = /^(?:\w+\:\/\/)?([^\/]+)([^\?]*)\??(.*)$/.exec(url);
hostname = urlParts[1]; // www.example.com
path = urlParts[2]; // /path/to/somwhere