js获取站点根目录
function getRootPath(){
var strFullPath=window.document.location.href;
var strPath=window.document.location.pathname;
var pos=strFullPath.indexOf(strPath);
var prePath=strFullPath.substring(0,pos);
var postPath=strPath.substring(0,strPath.substr(1).indexOf('/')+1);
return(prePath+postPath);
}
-----------------
//js获取项目根路径,如: http://localhost:8080/ems
getRootPath:function () {
//获取当前网址,如: http://localhost:8080/ems/Pages/Basic/Person.jsp
var curWwwPath = window.document.location.href;
//获取主机地址之后的目录,如: /ems/Pages/Basic/Person.jsp
var pathName = window.document.location.pathname;
var pos = curWwwPath.indexOf(pathName);
//获取主机地址,如: http://localhost:8080
var localhostPath = curWwwPath.substring(0, pos);
//获取带"/"的项目名,如:/ems
var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
return(localhostPath + projectName);
}
js获取站点根目录的更多相关文章
- js获取网站根目录
//js获取网站根路径(站点及虚拟目录),获得网站的根目录或虚拟目录的根地址 function getRootPath(){ var strFullPath=window ...
- js获取项目根目录的方法
getRootPath = function(){ //获取当前网址,如: http://localhost:8080/ems/Pages/Basic/Person.jsp var curWwwPat ...
- asp.net获取站点根目录下子目录的名称
使用Visual Studio建立一个.aspx文件(Web Forms),例如hovertree.aspx,在页面上加入一个ListBox代码如下: <asp:ListBox runat=&q ...
- JS获取项目根目录
function getRootPath(){ //获取当前网址,如: http://localhost:8088/test/test.jsp var curPath=window.document. ...
- js获取当前根目录的方法
function getRootPath_web() { //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp var curWwwP ...
- PHP获取站点根目录
http://rmingwang.com/php-access-to-the-site-root-directory.html php绝对路径与相对路径详解完整版 http://www.phpthin ...
- PHP中如何获取网站根目录物理路径
在php程序开发中经常需要获取当前网站的目录,我们可以通过常量定义获取站点根目录物理路径,方便在程序中使用. 下面介绍几种常用的获取网站根目录的方法. php获取网站根目录方法一: <?php ...
- js 获取 根目录
//js获取项目根路径,如: http://localhost:8083/uimcardprjfunction getRootPath(){ //获取当前网址,如: http://localhost: ...
- php获取网站根目录
php获取网站根目录方法一:<?phpdefine("WWWROOT",str_ireplace(str_replace("/","\\&quo ...
随机推荐
- Introduction of Servlet Filter(了解Servlet之Filter)
API文档中介绍了public Interface Filter(公共接口过滤器) Servlet API文档中是这样介绍的: ‘A filter is an object that performs ...
- Java ConcurrentHashMap的小测试
今天正式开始自己的分布式学习,在第一章介绍多线程工作模式时,作者抛出了一段关于ConcurrentHashMap代码让我很是疑惑,代码如下: public class TestClass { priv ...
- java常用API之System类
System中代表程序所在系统,提供了对应的一些系统属性信息,和系统操作.System类不能手动创建对象,因为构造方法被private修饰,阻止外界创建对象.System类中的都是static方法,类 ...
- drupal基础
http://www.cnblogs.com/yaoliang11/archive/2009/07/31/1535883.html
- Popularize what is heart of mobile phone?
From: http://tech.sina.com.cn/mobile/n/2014-09-29/08399657494.shtml 只谈核数没意义 带你重新认识手机SoC 2014年09月29日 ...
- Android.mk添加第三方jar包
最近引入第三方的jar包进工程,发现光红色的两条并不起作用,加入include $(BUILD_MULTI_PREBUILT) 才起作用,而且顺序很重要,在这里把我参考的两个例子都列出来. 以下为引用 ...
- office转换为html在线预览
/// <summary> /// word 转换为html /// </summary> /// <param name="path">要转换 ...
- mybooklist.cn 书单de故事六月十六日
1.我的30年30本书 刘苏里书单北京万圣书园总经理,以经营人文社科类图书著称.生于1960年,1983年毕业于北京大学国际政治系,1986年毕业于中国政法大学研究生院.
- ubuntu14.04安装rabbitmq
ubuntu14.04安装rabbitmq及配置 1.修改/etc/apt/sources.list文件 命令:vi /etc/apt/sources.list 在最后一行加上:deb http: ...
- asyncio标准库7 Producer/consumer
使用asyncio.Queue import asyncio import random async def produce(queue, n): for x in range(1, n + 1): ...