我有这个 main.html 文件,其中有一个“按钮”类型的按钮。它有一个 create()函数来处理 onclick 事件。
我还有另一个页面 test.html ,它与 main.html 位于同一个文件夹中。
我想要的是什么:
我不明白该怎么做。我读到了window.open(),但我想这只是一个弹出窗口,我想要一个完整的页面。
答案 0 :(得分:3)
在main.html中:
<input type='button' onclick='location.href=test.html' value='click me'>
&#13;
test.html中的
function create() {
// Write something in the page
}
&#13;
<body onload='create()'>
</body>
&#13;
答案 1 :(得分:1)
function create()
{
window.location = 'test.html';
}
这是你的出发点。然后,您需要在test.html文件中添加一些PHP或JS。
例如,您可以从网址获取您要撰写的邮件。
主档案: function create() { window.location =&#39; test.php?p = Hello%World&#39 ;; } 测试文件:
您还可以在测试文件中编写一个JS函数,该函数会在加载页面后立即调用。
主档案:
function create() // Create function on 1st page
{
window.location = 'test.html';
}
&#13;
测试文件:
<head>
<script type="text/javascript">
function message()
{
document.getElementById('container').innerHTML = 'Hello world';
}
</script>
</head>
<body onload="message();">
<div id="container"></div>
</body>
&#13;
希望它有所帮助。