我有以下两个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/