歡迎大家來參考
<!DOCTYPE html>
<html>
?<head>
? <title>練習</title>??
? <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />? ?
? <script type="text/javascript">??
? ? ?function openWindow(){
? ? ? ? var pd=confirm("是否打開新窗口");
? ? ? ? if(pd==true){
? ? ? ? var herf = prompt("請輸入你要打開的網址,默認是http://www.xianlaiwan.cn","http://www.xianlaiwan.cn");
? ? ? ? ? ?if(herf!="") {
? ?if(herf!=null){
? ? ? ? ? ? ? ?window.open(herf,"_blank","width=400,height=500,menubar=no,toolbar=no,scrollbars=yes");
? ?}
? ?else
? ?{
? alert("你取消了輸入");
? ?}
? }
? ? ? ? ? ? else{
? ? ? ? ? ? ? ? ?alert("輸入不能為空");
? ? ? ? }
}
else{
alert("你沒有選擇打開新窗口");
}
}
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
2019-05-08
這個!是什么作用
??if(herf!="") {
? ?if(herf!=null){
2019-05-07
如有錯誤望指出