获取网站的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

posted @ 2015-03-31 14:28  岳帅超  阅读(2428)  评论(0编辑  收藏  举报