你的位置:首页 > Java教程

[Java教程]获取网站的BaseURL


//get base URL
            var _urlstr = window.location.href;
            if (_urlstr.indexOf("?") > -1) {
                _urlstr = _urlstr.substring(0, _urlstr.lastIndexOf("?"));
            }
            _urlstr = _urlstr.substring(0, _urlstr.lastIndexOf("/"));
            _urlstr = _urlstr.substring(0, _urlstr.lastIndexOf("/"));

例如:http://localhost:1781/tool/yakujihou.aspx

_urlstr为:http://localhost:1781