function getBasePath(){
var obj=window.location;
var contextPath=obj.pathname.split("/")[1];
var basePath=obj.protocol "//" obj.host "/" contextPath;
return basePath;
}
javascript object contains 1. The top-level object of window javascript
2.navigator client browser information
3.screen client display information
4.history url information visited by the browser window
5.location current url information
where the location object Contains
For example, there is such an html address http://localhost:8080/huyao_soccer/huyao/tag/myplugin.jsp
1.hash
2.host host name and The port number of the current url is returned: localhost:8080
3.hostname The host name is returned: localhost
4.href The complete url is returned: http://localhost:8080/huyao_soccer/huyao/ tag/myplugin.jsp
5.pathname Returns the path part of the current url:/huyao_soccer/huyao/tag/myplugin.jsp
6.port Port number returns: 8080
7.protocol protocol returns: http:
8.search url section starting from ? (query part)