如果重新访问,如何关闭上一页

时间:2016-03-16 19:30:31

标签: javascript html forms

我有以下两个html文件。 submit.html在提交时打开newPage.html,newPage.html在提交时打开submit.html。问题是submit.html正在隐藏的iframe中播放音频文件。如何关闭submit.html,以便在重新审视页面时音乐不能自行播放?

submit.html

<!DOCTYPE html>
<html>   
<head>
    <meta charset="ISO-8859-1">
    <title>Submit</title>
</head> 
<body>

   <iframe src="http://localhost/Audio/src/audio.html" style="width:0;height:0;border:0; border:none;"></iframe>  


   <form target="newPage" action=NewPage.html>
      <input type="submit" value="click">
   </form>

</body>
</html>

newPage.html

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>newPage</title>
</head>
<body>
   here we are

   <form action="submit.html">
      <input type="submit" value="click">
   </form>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

最简单的方法是在按钮点击时关闭第一个sumbit.html页面,如下所示:<input type="button" value="click" action="NewPage.html" onclick="self.close()">

这样,当你在newpage.html上提交时,只会打开一个页面实例。

另一个更好的选择是创建一个脚本:

<script language="javascript" type="text/javascript"> 
function windowClose() { 
window.open("http://www.yourdomain.com/submit.html"); 
window.close();
} 
</script>

HTML

<input type="button" value="Click" onclick="windowClose();">

相关问题