手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >获取网站跟路径的javascript代码(站点及虚拟目录)
获取网站跟路径的javascript代码(站点及虚拟目录)
摘要:复制代码代码如下:functiongetRootPath(){varstrFullPath=window.document.location...

复制代码 代码如下:

<script>

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);

}

alert (getRootPath());

</script>

【获取网站跟路径的javascript代码(站点及虚拟目录)】相关文章:

javascript基于DOM实现权限选择实例分析

解析javascript中鼠标滚轮事件

理解javascript中的with关键字

数字金额千位分隔的Javascript

javascript验证邮件地址和MX记录的方法

javascript实现行拖动的方法

javascript+HTML5自定义元素播放焦点图动画

javascript结合Flexbox简单实现滑动拼图游戏

javascript中DOM复选框选择用法实例

在JavaScript中使用NaN值的方法

精品推荐
分类导航