$kernelink route --hydrate --safe

页面加载 /
跳到正文
auth://account/session

登录工作区

使用 Emlog 账户继续访问你的内容与互动记录。

忘记密码?

打开 Emlog 原生登录页

219.md
workspace / posts
~/posts/219.md 阅读中

网站屏蔽PC端访问,只允许手机端访问的技巧!

网站屏蔽PC端访问JS代码,只允许手机端访问

可以使用以下的JavaScript代码来实现这个需求。这段代码250;检查当前设备的屏幕宽度,如果小于某个阈值(通常为600px),则将用户重定向到另一个页面同时,这段代码还会检测用户的操作系统类型,以决定是否允许访问该网站。

<script type="text/javascript">
    if (window.screen.width <= 0) { // 如果屏幕宽度为0,即当前设备为手机或平板
        window.location.replace("http://www.zzmaku.com");
    }
    var system = {
        win: false,
        mac: false,
        xll: false
    };
    var p = navigator.platform;
    system.win = p.indexOf("Win") == 0;
    system.mac = p.indexOf("Mac") == 0;
    system.xll = p == "X11" || p.indexOf("Linux") == 0;
    if (system.win || system.mac || system.xll) { // 如果设备为电脑或平板,则跳转到其他页面
        location.replace("http://这里替换为你需要跳转的页面网址");
    }
</script>

这段代码可以放在网站的底部,以确保在用户尝试访问PC端时立即执行同时,为了防止用户使用开发者工具查看和修改这段代码,建议将其放在<body>标签的最后,或者使用一些防篡改技术。

以上内容已经用Markdown格式进行了排版,使其更易于阅读。

收藏 0
手机扫码阅读

微信或手机浏览器扫一扫,随时随地随心阅读与分享

comments.cmd 可写入
guest@kernelink:~/posts/219$ comment --compose
identity.env 访客信息
插入 访客会话 Text + UBB · UTF-8 · LF 0 字符
收到1条评论
Pseudomonas aeruginosa bacteraemia episode was defined as a patient with consistent clinical illness having PA isolated from one or more of the aerobic or anaerobic bottles of their blood culture <a href=https://fastpriligy.top/>where to buy priligy</a> Fertility programs are more competitive than ever