美文网首页
防止恶意嵌套网站

防止恶意嵌套网站

作者: 海豚先生的博客 | 来源:发表于2020-06-16 14:58 被阅读0次
      try {
        // 获取顶级对象
        top.location.hostname;
        // 兼容chrome
        if (top.location.hostname != window.location.hostname) {
          top.location.href = window.location.href;
        }
      } catch (e) {
        // 如果报错就重定向到自己的网站
        top.location.href = window.location.href;
      }

相关文章

网友评论

      本文标题:防止恶意嵌套网站

      本文链接:https://www.haomeiwen.com/subject/pjqrxktx.html