/** * All rights Reserved, Designed By ICT.CARS * @Title: init.js * @Description: TODO(用一句话描述该文件做什么) * @author: Darkorbit * @date: 2016年5月3日 上午9:42:47 * @version V1.0 */ //解决IE浏览器对startsWith属性的兼容问题 if (typeof String.prototype.startsWith != 'function') { String.prototype.startsWith = function (prefix){ return this.slice(0, prefix.length) === prefix; }; } console.log(location.pathname.replace(/\/[^/]*$/, '')); var scripts = document.getElementsByTagName("script"); var baseSrc = ""; for (var i = 0;i=0){ baseSrc = scripts[i].src.substr(0,eindex); } } console.log(baseSrc) //dojo配置项 if(!!dojoConfig){ dojoConfig.packages.push({ name: "rgis", location: baseSrc+'rgis'}); }else{ var dojoConfig = { packages:[ { name: "rgis", location: baseSrc+'rgis'} ] } } //加载本地资源文件dojo var getDojoPath = function(){ if(baseSrc.indexOf("://")>=0){ return baseSrc.substr(baseSrc.indexOf("://")+3)+"dojo"; } return baseSrc+"dojo"; }; //加载本地3.22资源文件 document.write(""); document.write(""); document.write(""); /** * js获取项目根路径, * 如: http://localhost:8080/rgis */ function getRootPath() { var curWwwPath = window.document.location.href; var pathName = window.document.location.pathname; var pos = curWwwPath.indexOf(pathName); var localhostPath = curWwwPath.substring(0, pos); var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1); //console.log(localhostPath); //console.log(projectName); //当设置ip+项目名称访问系统时 return (localhostPath + projectName); //当设置ip直接访问系统时 //return (localhostPath); }; /** * js获取项目根路径(不含http://) * 如: localhost:8080/rgis */ function getHostPath() { var _path = getRootPath(); var _hostPath = _path.substring(7, _path.length); //console.log(_hostPath); return _hostPath; };