Reputation: 831
I have this main.html file which has a button of type "button". It has a create() function that processes the onclick event.
I also have another page test.html which is in the same folder as the main.html.
What I want:
I don't understand how to do it. I read about window.open() but I guess this is just a pop up, and I want a full-fledged page.
Upvotes: 1
Views: 17488
Reputation: 165
function create()
{
window.location = 'test.html';
}
This is your starting point. Then, you need to add some PHP or JS to your test.html file.
For example, you can get a message from the URL, that you're going to write.
Main file: function create() { window.location = 'test.php?p=Hello%World'; } Test file:
You can also write a JS function in your test file, which is called as soon as the page is loaded.
Main file:
function create() // Create function on 1st page
{
window.location = 'test.html';
}
Test file:
<head>
<script type="text/javascript">
function message()
{
document.getElementById('container').innerHTML = 'Hello world';
}
</script>
</head>
<body onload="message();">
<div id="container"></div>
</body>
Hope it helped.
Upvotes: 1
Reputation: 94
In the main.html:
<input type='button' onclick='location.href=test.html' value='click me'>
in test.html
function create() {
// Write something in the page
}
<body onload='create()'>
</body>
Upvotes: 3