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)
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn