前端随记(禁止直接页面跳转 、http-equiv=“refresh“ 网页自动跳转)

1、禁止直接页面跳转.js

window.onload=function(){
    //排除特定页面
    if (this.location.href.indexOf("UI/src/views/home/console.html") > 0 || this.location.href.indexOf("UI/src/views/user/login.html") > 0 ||
        this.location.href.indexOf("UI/src/views/user/forget.html") > 0 || this.location.href.indexOf("UI/src/views/user/forget.html") > 0 || this.location.href.indexOf("UI/src/views/user/reg.html") > 0
        || this.location.href.split("UI/src/views/")[1] == ""
    ) {
        return;
    }
    //禁止直接页面跳转
    //console.log(this.location.href.split("UI/src/views/")[1]=="");
    if (top.location.href == this.location.href && this.location.href.split("UI/src/views/")[0] != "") {
        location.replace("../StatePage/IllegalJumpPage.html");
        return;
    }
}


// http://192.168.1.17:8088/UI/src/views/ActivityCenter/CreateActivity.html

效果是:open in new tab 或者复制里面的url 到新建网页运行访问的话,直接让其跳转进入IllegalJumpPage.html 。

2 META http-equiv=“refresh” 实现网页自动跳转

default.htm内容:

  <meta http-equiv="refresh" content="0; url=UI\src\views\user\login.html" />

环境如下:IIS项目文件夹下创建个default.htm ,IIS的默认文档将default.htm置顶。

效果是访问:http://192.168.1.19:8063/ 自动跳转> http://192.168.1.19:8063/UI/src/views/user/login.html

再添加个例子:

root@ggwlq-PC:/var/www/html# cat index.php 
<head>
<meta http-equiv="refresh" content="0;url=IT_home/IT_login.php"> 
</head>

在这里插入图片描述

参考:https://www.cnblogs.com/lixihuan/p/6824871.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值