限制网页只在手机端中打开,网站屏蔽PC端访问JS代码,网站只允许手机端访问
{hide}
<script type="text/javascript">
if(window.screen.width==0){window.location.replace("https://www.heylie.cn")};
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.x11=(p=="X11") || (p.indexOf("Linux")==0);
if(system.win||system.mac||system.xll) {
location.replace("https://www.heylie.com");
}
</script>
{/hide}
屏蔽右键菜单
{hide}
<script type="text/javascript">
document.oncontextmenu = function(event) {
if (window.event) {
event = window.event;
}
try {
var the = event.srcElement;
if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
return false;
}
return true;
} catch (e) {
return false;
}
}
</script>
{/hide}
屏蔽粘贴
{hide}
<script type="text/javascript">
document.onpaste = function(event) {
if (window.event) {
event = window.event;
}
try {
var the = event.srcElement;
if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
return false;
}
return true;
} catch (e) {
return false;
}
}
</script>
{/hide}
屏蔽复制
{hide}
<script type="text/javascript">
document.oncopy = function(event) {
if (window.event) {
event = window.event;
}
try {
var the = event.srcElement;
if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
return false;
}
return true;
} catch (e) {
return false;
}
}
</script>
{/hide}
屏蔽剪切
{hide}
<script type="text/javascript">
document.oncut = function(event) {
if (window.event) {
event = window.event;
}
try {
var the = event.srcElement;
if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
return false;
}
return true;
} catch (e) {
return false;
}
}
</script>
{/hide}
屏蔽选中
{hide}
<script type="text/javascript">
document.onselectstart = function(event) {
if (window.event) {
event = window.event;
}
try {
var the = event.srcElement;
if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) {
return false;
}
return true;
} catch (e) {
return false;
}
}
</script>
{/hide}
禁用右键(防止右键查看源代码)
{hide}
<script type="text/javascript">
//禁用右键(防止右键查看源代码)
window.oncontextmenu=function(){return false;}
//禁止任何键盘敲击事件(防止F12和shift+ctrl+i调起开发者工具)
window.onkeydown = window.onkeyup = window.onkeypress = function () {
window.event.returnValue = false;
return false;
}
//如果用户在工具栏调起开发者工具,那么判断浏览器的可视高度和可视宽度是否有改变,如有改变则关闭本页面
var h = window.innerHeight,w=window.innerWidth;
window.onresize = function () {
if (h!= window.innerHeight||w!=window.innerWidth){
window.close();
window.location = "about:blank";
}
}
</script>
{/hide}
THE END
请登录后发表评论
注册
社交账号登录