Home > front end >  how to set page title on about:blank website
how to set page title on about:blank website

Time:11-06

I am making a school game unblocker website and am using about:blank cloaking. I need to add a title to the about:blank site so that teachers won't see what I am on.

This is the code for the redirection.

<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>

This is what the Main.html code looks like. This is the about:blank site.

<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>

If i just run the second file, it does not do the about:blank but does show the title. Thank you!

CodePudding user response:

You can set the title of the new window using win.document.title = "Your Title Here";

Example:

<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>
  • Related