html 如何在about:blank website上设置页面标题

eyh26e7m  于 2022-12-09  发布在  其他
关注(0)|答案(2)|浏览(167)

我正在制作一个学校游戏的反拦截器网站,并且正在使用about:blank cloaking。我需要在about:blank网站上添加一个标题,这样老师就看不到我在做什么了。
这是用于重定向的代码。

<html>

<head>

<body onclick="MyWindow1()">Click here to start</body>


</head>

<script>

(url);

var newWin = window.open
function MyWindow1(){

var win = window.open()
var iframe = win.document.createElement('iframe')
iframe.style.width = "100%";
iframe.style.height = "100%";
iframe.style.border = "none";
iframe.src = "./Main.html";
win.document.body.appendChild(iframe)
location.replace("https://www.google.com/")
}


</script>

</html>

这是Main.html代码的样子。这是about:blank站点。

<html>

<head>

<body onclick="MyWindow1()">Click here to start</body>


</head>

<script>

(url);

var newWin = window.open
function MyWindow1(){

var win = window.open()
var iframe = win.document.createElement('iframe')
iframe.style.width = "100%";
iframe.style.height = "100%";
iframe.style.border = "none";
iframe.src = "./Main.html";
win.document.body.appendChild(iframe)
location.replace("https://www.google.com/")
}


</script>

</html>

如果我只运行第二个文件,它不会显示about:blank,但会显示标题。谢谢!

xnifntxz

xnifntxz1#

可以使用win.document.title = "Your Title Here";设置新窗口的标题
示例:

<script>
    (url);
    var newWin = window.open
    function MyWindow1() {
        var win = window.open()
        win.document.title = "Your Title Here";
        var iframe = win.document.createElement('iframe')
        iframe.style.width = "100%";
        iframe.style.height = "100%";
        iframe.style.border = "none";
        iframe.src = "./Main.html";
        win.document.body.appendChild(iframe);
        location.replace("https://www.google.com/");
    }
</script>
yvt65v4c

yvt65v4c2#

您不需要这样做。在任何屏幕查看应用程序中,该页面和页面标题都不会显示。

相关问题