获取网站跟路径的javascript代码(站点及虚拟目录)
作者:bea
代码如下: <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=
代码如下:
<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 炫彩的文字
- Javascript 小写字母依次变为大写
- Js+CSS 文字渐隐渐现显示
- Domino中运用jQuery读取视图内容的方法
- JS 截取字符串substr 和 substring方法的区别
- JavaScript 常用函数库详解
- 再谈ie和firefox下的document.all属性
- 用Javascript 编写可以缓慢弹出收缩的层
- javascript void(0)的妙用
- extjs 学习笔记 四 带分页的grid
- Jquery Ajax.ashx 高效分页实现代码
- fireworks菜单生成器mm_menu.js在 IE 7.0 显示问题的解决方法
- Javascript remove 自定义数组删除方法
- JavaScript 事件记录使用说明
- 7个Javascript地图脚本整理
- JavaScript 自动完成脚本整理(33个)
- javascript 添加和移除函数的通用方法
- JS 用6N±1法求素数 实例教程