我這么寫對么
否則沒有任何操作的話我是要關閉新打開的窗口么,那用close怎么關捏,,,
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/> ??
? <script type="text/javascript"> ?
? function openWindow(){
? ? // 新窗口打開時彈出確認框,是否打開
? ? window.open('_blank');
? ? var haha=window.open('_blank');
? ? ?var mymessage=confirm("是否打開新窗口?");
? ? ? ? ?// 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? ?if(mymessage=true)
? ? ?{
? ? ? ? ?window.open('http://www.xianlaiwan.cn/','_self','width=400,height=500,menubar=no,toolbar=no');
? ? ?}
? ?
? ? } ? ?
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
2016-03-30
??????? 打開了新窗口是跳轉到其他頁面了? 這里無法寫window.close();
因為本頁面的腳本干預不到新窗口
2016-03-30
? ? function openWindow(){
? ? // 新窗口打開時彈出確認框,是否打開
? ? var myconfirm=confirm("是否打開");
? ? if(myconfirm==true){
? ? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
? ? var myprompt=prompt("確定打開的網址:","http://www.xianlaiwan.cn");
? ? if(myprompt!=null){
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ?window.open(myprompt,'_self','width=400,height=500,menubar=no,toolbar ? ? ? ? ? ?=no');
? ? ? ??
? ? } ? ?
? ? }
? ? }?
2016-03-30
function openWindow(){
? ? var mywindow1=confirm("是否打開新窗口?")
? ? ?if(mywindow1==true)
? ? ?{
? ? ? ?var one=window.open('http://www.xianlaiwan.cn/',
'_blank','width=400,height=500,menubar=no,toolbar=no');
? ? ? ? var mywindow2=confirm("是否關閉新窗口?")
? ? ? ? if(mywindow2==true) {
? ? ? ? ? ? one.close();
? ? ? ? }
? ? ?} else {
? ? ? ? ?
? ? ?}
? }
2016-03-30
?function openWindow(){
??????? var result=confirm("是否打開新窗口?");//先要判斷是否打開窗口,
??????? if(result==true){//想打開窗口,不想打開新窗口就沒有下文了
??????????? var yes=prompt("打開窗口:","http://www.xianlaiwan.cn/");
??????????? if(yes){//返回想打開窗口的情況,這里是想打開的情況
??????????? window.open(yes,"_blank","width=400px.height=500px,menubar=no,toolbar=no")
??????????? }
??????????
??????????? }
??????? }