码迷,mamicode.com
首页 > Web开发 > 详细

js 处理浏览器显示地址

时间:2019-08-29 11:52:23      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:round   ==   ack   path   elf   pre   输入   pat   rip   

输入 www.test.com、www.test.com/home

显示 www.test.com/home/index

    <script>
        $(function () {
            //浏览器地址处理
            if (window.location.pathname.toLowerCase().indexOf("home") == -1) {
                var pathname = window.location.pathname;
                pathname = pathname + ‘/home/index‘;
                pathname = pathname.replace("//", "/")
                window.open(window.location.origin + pathname, ‘_self‘);
            } else if (window.location.pathname.toLowerCase().indexOf("index") == -1) {
                var pathname = window.location.pathname;
                pathname = pathname + ‘/index‘;
                pathname = pathname.replace("//", "/")
                window.open(window.location.origin + pathname, ‘_self‘);
            }
        });
    </script>

 

js 处理浏览器显示地址

标签:round   ==   ack   path   elf   pre   输入   pat   rip   

原文地址:https://www.cnblogs.com/wxy520/p/11428436.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!