I want it so that every time a button is clicked, a new page with a random name is generated (i. e. HuJ8a7-Op_z6.html).
How can i do that using HTML & JS?
I want it so that every time a button is clicked, a new page with a random name is generated (i. e. HuJ8a7-Op_z6.html).
How can i do that using HTML & JS?
You would need to use server side code to do this.
Wait, i think i just figured it out…
<html>
<head>
<title>Website</title>
<script>
function test() {
var opened = window.open("test.html");
opened.document.write("<html><head><title>MyTitle</title></head><body>test</body></html>");
}
</script>
</head>
<body>
<h1>Welcome</h1>
<p>
<button onclick="test();">Link to new page</button>
</p>
</body>
</html>
I’ll add the randomly-generated string later,
Anyways, i need it to create a new page. However, this will just open about:blank and add the specified code in there!
Just a heads up that this will not save, but glad you figured it out.
So how do i make it create a new page?
Read this First
Yeah, i did.
I would recommend that you look into file creation in what server side language you prefer.
JS? Is that possible with JS?
Client side? No.
I guess that you only know HTML and the js. But want to do many things that need server side of code. So if you have not of the already you should learn node or the php
NodeJS?
I’m using hello-sqlite
Just to understand , do you know of the node js language ?
Long-story-short: Kind-of
Like we said, please look into file creation in your server side language.
That’s makes no sense. You of either know it or dont
If you’re learning Node, you can start by reading the docs, it’s not as painful as some other docs
Mark that post for the answer @no_one if you are the done with help and understand
var fs = require('fs');
fs.writeFile('mynewfile3.txt', 'Hello content!', function (err) {
if (err) throw err;
console.log('Saved!');
});
Is this right?
The docs should tell you if it is right or not. Did you read them?