Home > Web Front-end > JS Tutorial > Get the javascript code of the website and path (site and virtual directory)_javascript skills

Get the javascript code of the website and path (site and virtual directory)_javascript skills

WBOY
Release: 2016-05-16 18:44:04
Original
1177 people have browsed it
复制代码 代码如下:

<script> <br>function getRootPath(){ <br>var strFullPath=window.document.location.href; <br>var strPath=window.document.location.pathname; <br>var pos=strFullPath.indexOf(strPath); <br>var prePath=strFullPath.substring(0,pos); <br>var postPath=strPath.substring(0,strPath.substr(1).indexOf('/') 1); <br>return(prePath postPath); <br>} <br>alert (getRootPath()); <br></script>
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template