參數.close問題,為什么關閉不了頁面呢
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>close()</title>
? <script type="text/javascript">
???? function ass(){
???? var mywin= window.open("http://www.baidu.com");
???? var pages = confirm("是否關閉頁面?");
???????? if(pages == true){
???????????? mywin.close();
???????????? alert("成功關閉");
???????? }else{
???????????? alert("沒有關閉");
???????? }
???? }
? </script>
</head>
<body>
<input type="button" value="點我下試試" onclick="ass()" />
</body>
</html>
為什么點確認鍵,新打開的頁面還是無法關閉呢
2015-12-03
<!DOCTYPE?HTML> <html> <head> ????<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/> ????<title>close()</title> ????<script?type="text/javascript"> ????????function?ass(){ ????????????var?mywin=?window.open("http://www.xianlaiwan.cn/"); ????????????var?pages?=?confirm("是否關閉頁面?"); ????????????if(pages?==?true){ ????????????????mywin.close(); ????????????????alert("成功關閉"); ????????????}else{ ????????????????alert("沒有關閉"); ????????????} ????????} ????</script> </head> <body> <input?type="button"?value="點我下試試"?onclick="ass()"?/> </body> </html>換成慕課網也沒有問題
2015-12-02
我這測試 ,你的代碼是沒有問題的,注意關閉的不是當前頁面,而是重新打開的一個頁面。