答案答案答案
<!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 flag = confirm("是否打開網頁?")
? ? ? ??
? ? ? ? if(flag==true){
? ? ? ? ? ?var url = prompt("請輸入網址","http:www.xianlaiwan.cn")
? ? ? ? ? ?if(url !=""){
? ? ? ? ? ? ??
? ? ? ? ? ? ? ? window.open(url,"_blank","width=400","height=500","menubar=no","toolbar")
? ? ? ? }else{
? ? ? ? ? ? window.close()
? ? ? ? ? ? ?}
? ? ? ? }
? ? ? ??
? ? ?}? ? ?
? ??
? ??
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
2018-06-21
function?openWindow(){? ????var?message?=?confirm("是否打開新窗口");? ????if(message?==?true){? ???????????var?url="http://www.xianlaiwan.cn/";?//默認地址? ???????????url=?prompt("請輸入需要打開的網址",url);?//可以修改默認地址,修改你想跳轉的頁面???????? ???????????if(url){??????????????????????? ????????????????window.open(url,"_blank","width=400px,height=500px,menubar=no,toolbar=no");???????? ???????????}???? ??????}else{ ???????????document.write("謝謝欣賞?。?!");???? ??????}???? ?}