JavaScript close()方法无效?
本文介绍了JavaScript close()方法无效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>window.open测试</title>
<script>
function openWin(){
myWindow=window.open(",","my","width=400,height=400,top=50,left=10");
myWindow.document.write("<p>这是'我的窗口");
myWindow.document.write("<br>ScreenLeft: " + myWindow.screenLeft);
myWindow.document.write("<br>ScreenTop: " + myWindow.screenTop + "</p>");
}
function close(){
myWindow.close();
}
</script>
</head>
<body>
<input type="button" value="打开 '我的窗口'" onclick="openWin()">
<input type="button" value="关闭窗口" onclick="close()">
</body>
不知道为什么会无法关闭标签页,百度了下其他close方法也不行,求解
解决方案
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>window.open测试</title>
<script>
function openWin(){
myWindow=window.open(",","my","width=400,height=400,top=50,left=10");
myWindow.document.write("<p>这是'我的窗口");
myWindow.document.write("<br>ScreenLeft: " + myWindow.screenLeft);
myWindow.document.write("<br>ScreenTop: " + myWindow.screenTop + "</p>");
}
function closeWin(){
myWindow.close();
}
</script>
</head>
<body>
<input type="button" value="打开 '我的窗口'" onclick="openWin()">
<input type="button" value="关闭窗口" onclick="closeWin()">
</body>
</html>
把close()改成closeWin()
这篇关于JavaScript close()方法无效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文