這么寫還有優化的空間嗎
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title>??
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>? ?
? <script type="text/javascript">??
? ? // 新窗口打開時彈出確認框,是否打開
? ? function openWindow(){
? ? var message=confirm("是否打開新網頁?");
? ? if(message==true)
? ? {
? ? window.open('http://www.xianlaiwan.cn','_blank','width=400,height=500,top=100,left=0,toolbar=no,menubar=no');
? ? }
? ? else
? ? {
? ? ? ? return null;
? ? }
? }? ??
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
2019-11-13
function?openWindow(){ ????????var?Message?=?confirm("Are?you?sure?want?to?open?a?site?"); ????????if(Message?==?true){ ????????????var?URL?=?prompt("Enter?an?url?to?open","http://www.xianlaiwan.cn/") ????????????while?(URL?===?""){ ????????????????alert("Please?enter?an?url"); ????????????????var?URL?=?prompt("Enter?an?url?to?open","http://www.xianlaiwan.cn/"); ????????????????} ????????????????if?(URL?!=?null)?{ ????????????????????window.open(URL,"_blank","width=400,height=500,menubar=no,toolbar=no"); ????????????????}?else?{ ????????????????????return; ????????????????} ????????}?else?{ ????????????return; ????????} ????}2019-11-04
少滿足一個要求