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

标签 javascript html forms

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

提交.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>

最佳答案

最简单的方法是在单击按钮时关闭第一个 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();">

关于javascript - 如果重新访问如何关闭上一页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36045275/

相关文章:

javascript - Array#map() 中的异步/等待

javascript - 如何将以前的功能添加到简单的 jQuery slider

javascript - Firefox JavaScript 表单

javascript - 从 JQuery 模态对话框获取值提交到另一个输入类型

javascript - 使用 javascript 提交表单并从其他页面接收表单

javascript - 通过 HTTPS 在 OpenLayers map 中使用 Stamen tiles

javascript - 火狐3 : Enable AJAX to localhost from outside domain

javascript - gojs 中悬停按钮的自定义样式

java - html 单选按钮添加到数据库

html - 当静默模式打开时,如何关闭 Netbeans html 调试 Chrome 连接?