function getRealPath(){
      //获取当前网址,如: http://localhost:8083/myproj/view/my.jsp
       var curWwwPath=window.document.location.href;
       //获取主机地址之后的目录,如: myproj/view/my.jsp
      var pathName=window.document.location.pathname;
      var pos=curWwwPath.indexOf(pathName);
      //获取主机地址,如: http://localhost:8083
      var localhostPaht=curWwwPath.substring(0,pos);
      //获取带"/"的项目名,如:/myproj
      var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
     //得到了 http://localhost:8083/myproj
      var realPath=localhostPaht+projectName;
      return realPath;
}

JS 获取WEB请求路径的更多相关文章

  1. java ,js获取web工程路径

    一.java获取web工程路径 1),在servlet可以用一下方法取得: request.getRealPath(“/”) 例如:filepach = request.getRealPath(“/” ...

  2. Servlet之ServletContext获取web上下文路径、全局参数、和Attribute(域)

    1)获取web上下文路径 public void doGet(HttpServletRequest request, HttpServletResponse response) throws Serv ...

  3. js获取项目根路径

    //js获取项目根路径,如: http://localhost:8083/uimcardprj function getRootPath(){ //获取当前网址,如: http://localhost ...

  4. java 或者 js 获取项目访问路径(域名)

    /** * 获得站点url * @return */ public String getWebUrl(){ String url = getRequest().getScheme() + " ...

  5. 获取web应用路径 // "/" 表示class 根目录

    /** * 获取web应用路径 * @Description : 方法描述 * @Method_Name : getRootPath * @return * @return : String * @C ...

  6. JS获取url请求参数

    JS获取url请求参数,代码如下: // 获取url请求参数 function getQueryParams() { var query = location.search.substring(1) ...

  7. 【转】Spring 获取web根目录 (Spring线程获取web目录/路径/根目录,普通类获取web目录)

    不使用Spring,怎样能在Listener启动的Thread中获取web目录,还真不完全确定.其实我觉得实际代码也很简单.就是基于普通的listener,然后在listener中获取web目录并放到 ...

  8. js 获取文件本地路径

    1.代码 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF- ...

  9. js 获取input file路径改变图像地址

    html代码 <img id="newImage" alt="100x100" src="__PUBLIC__/img/1.jpg" ...

随机推荐

  1. chrome emulator use-agent 设置 chrom模拟手机客户端

    谷歌升级以后,发现找不到use-agent设置了 在Element 下点击ESC 出现console,再点击Emulation就出现了

  2. 学习JQuery中文文档之map()函数和get()函数

    今天学到一个新的函数map(). map(callback) 官方概述: 将一组元素转换成其他数组(不论是否是元素数组) 你可以用这个函数来建立一个列表,不论是值.属性还是CSS样式,或者其他特别形式 ...

  3. java中final的用法

    final从字面翻译来看,有最后的,最终的;  决定性的;  不可更改的等含义,在java里面主要还是“不可改变的”这层意思,不可改变或者不想改变的final主要用在类.方法.数据这三个方面. 一.f ...

  4. hdu 1861-游船出租

    游船出租                                                                                   Time Limit: 1 ...

  5. jQuery日历和日期选取插件

    参考网站:http://developer.51cto.com/art/201103/248670.htm http://www.open-open.com/ajax/3_Calendar.htm 推 ...

  6. acdream 1409 Musical 状压DP

    链接:http://acdream.info/problem? pid=1409 题意:整个国家有n座城市,每座城市有三种粉丝. 第一种一周看一场音乐剧,挑选的音乐剧是已经在周围城市播放上演过的次数最 ...

  7. TP的一条sql语句(子查询)

    $model=M(''); $model->table(C('DB_PREFIX').'goods as g') ->join(C('DB_PREFIX').'orders as o on ...

  8. 网站性能扩展案例:每天30-50亿请求,300K QPS是如何炼成的

    Reduce Data广告服务网站(http://reducedata.com)如何扩展到每天300K QPS请求?分享经验如下: 1. 为大规模而设计,广告服务平台从一开始增长就很惊人,因此,系统开 ...

  9. CustomProgressBar

    https://github.com/eltld/CustomProgressBar-master

  10. Python基础教程之第2章 列表和元组

    D:\>python Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] on win32 Typ ...