[英]How can close the tab when open the new tab in same browser?
I have opened a website in a browser tab. 我已经在浏览器选项卡中打开了一个网站。 Now, when I open a new tab from this website, I want to close the first tab in that browser. 现在,当我从该网站打开一个新标签时,我想关闭该浏览器中的第一个标签。
Use this script 使用此脚本
<html>
<head>
<script type="text/javascript">
function click1() {
window.open("http://127.0.0.1/");
window.open("http://127.0.0.1/wordpress/?page_id=2");
}
function close1() {
var c="http://127.0.0.1/";
c.close();
}
function newwin (urllink) {
newwindow = window.open( urllink ,'newwin')
}
</script>
</head>
<body>
<a href="javascript:newwin('http://www.bbc.co.uk')">bbc</a><br>
<a href="javascript:newwin('http://www.google.co.uk')">google</a>
<form>
<input type="button" value="close me!!" onClick="close1()"/>
<input type="button" value="Close" onClick="window.newwindow.close()">
<form>
</body>
</html>
You cannot use PHP to close a window but you can use this script 您不能使用PHP关闭窗口,但可以使用此脚本
<script language="javascript" type="text/javascript">
function closeWindow() {
window.open('','_parent','');
window.close();
}
</script>
Please try this 请尝试这个
<script type="text/javascript">
function newwin (urllink) {
newwindow = window.open( urllink ,'newwin')
}
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.