htmlmeta content=width=device-width initial-scale=10 maximum-scale=10 user-scalable=0 name=viewport title加载中titlebody style=margin0;padding0;height100 scroll=noiframe id=infrm name=infrm marginwidth=0
您可以使用JavaScript来检测iframe展示的网址内容是否包含违规词,并在检测到违规词时跳转到指定网址。以下是一个示例代码:
<html>
<head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body style="margin:0;padding:0;height:100%" scroll=no>
<div id="paneloading" style="display:block;text-align:center;font-size:20px;padding-top:50px;">加载中...</div>
<div id="Zl" style="display:none;">
<iframe id="infrm" name="infrm" marginwidth="0" marginheight="0" width="100%" scrolling=auto src="http://auth.9a18.cn" frameborder="0" height="100%" allowfullscreen="true"></iframe>
</div>
<script>
$(document).ready(function(){
function fix_height() {
$("#infrm").attr("height", ($(window).height()-5) + "px");
}
$(window).resize(function() {
fix_height();
}).resize();
$("#infrm").contentWindow.focus();
});
var iframe = document.getElementById("infrm");
if (iframe.attachEvent) { // 兼容IE写法
iframe.attachEvent("onload", function(){
checkContent();
});
} else {
iframe.onload = function(){
checkContent();
};
}
function checkContent() {
var iframeContent = iframe.contentDocument.body.innerHTML.toLowerCase();
var bannedWords = ["代理", "验证", "网站"];
for (var i = 0; i < bannedWords.length; i++) {
if (iframeContent.includes(bannedWords[i])) {
top.location.href = "http://qq.com";
break;
}
}
document.title = ".";
top.document.getElementById("paneloading").style.display = "none";
top.document.getElementById("Zl").style.display = "";
}
</script>
</body>
</html>
这段代码使用了jQuery库来简化操作,首先在head标签中引入了jQuery库的CDN链接,然后在页面加载完成后,通过jQuery选择器和事件绑定来设置iframe的高度和焦点。在检测到iframe加载完成后,通过获取iframe的内容并将其转换为小写字母,然后与违规词列表进行匹配。如果匹配成功,则跳转到指定网址。同时隐藏加载中的提示,显示iframe的内容
原文地址: https://www.cveoy.top/t/topic/iTG3 著作权归作者所有。请勿转载和采集!