<!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?opwindow=confirm('是否要打開新窗口?')
????????if(opwindow==true){
????????????var?confirm=prompt('請輸入網址','例如:www.baidu.com')
????????????if(confirm!=null){
????????????????window.open(confirm,'_blank','width=400,height=500,menubar=yes,toolbar=yes')
????????????}
????????????else{
????????????????alert("你沒輸入網址")
????????????}
????????}
????????else{
????????????alert("滾出?。?!233333")
????????}
????}
????//?新窗口打開時彈出確認框,是否打開
????//?通過輸入對話框,確定打開的網址,默認為?http://idcbgp.cn/
????//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
????
????
??</script>?
?</head>?
?<body>?
??<input?type="button"?value="新窗口打開網站"?onclick="openWindow()"?/>?
?</body>
</html>
2016-03-24
var confirm=prompt('請輸入網址','例如:www.baidu.com')
不要用關鍵字“confirm”做變量
2016-03-24
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>window.open</title>
<script type="text/javascript">
? ? function op(){
? ? ? ? var mychar=confirm("是否要打開新窗口?");
? ? ? ? if(mychar==true){
? ? ? ? ? ?var con=prompt("請輸入網址:","例如:www.baidu.com");
? ? ? ? ? ?if(con!=null){
? ? ? ? ? ? ? ? window.open(con,'_blank','width=400,height=500,menubar=yes,toolbar=yes');
? ? ? ? ? ? }
? ? ? ? ? ? else{
? ? ? ? ? ? ? ? alert("你沒輸入網址");
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? else{
? ? ? ? ? ? alert("滾出!??!233333");
? ? ? ? }
? ? ? }
? ? ? ?
</script>
</head>
<body>
? ? <input name="button" type="button" onClick="op()" value="點擊我,打開新窗口!" / >
</body>
</html>
2016-03-24
confirm是關鍵字,不能作為變量名使用
?var?confirm1=prompt('請輸入網址','例如:www.baidu.com')
????????????if(confirm1!=null){
????????????????window.open(confirm1,'_blank','width=400,height=500,menubar=yes,toolbar=yes')
????????????}
2016-03-24
不要用關鍵字做變量名
2016-03-24
10. var?confirm=prompt('請輸入網址','例如:www.baidu.com');
“confirm”是關鍵字,不能做變量聲明,將confirm改為其他非關鍵字的合法名稱即可。
2016-03-24
謝謝大家,是第一個的問題,不要用關鍵字“confirm”做變量
2016-03-24
<!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 ac=confirm("是否打開新窗口?");
? ? ? ? if(ac==true){
? ? ? ? var url=prompt("請輸入要打開的網址","http://idcbgp.cn/"); ? ? ? ??
if(url!=null){?
window.open(url,'_blank','width=400px,height=500px,menubar=no,toolbar=no');}
? ? ? ? ? else{
? ? ? ? ? ? ? alert("bye")
? ? ? ? ? }
? ? ? ? }
? ? ? ? else{
? ? ? ? ? ? alert("see you")
? ? ? ? }
? ? ? ? }// 新窗口打開時彈出確認框,是否打開
? ? // 通過輸入對話框,確定打開的網址,默認為 http://idcbgp.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ??
?</script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
這是我的代碼,親測有效;應該是細節(jié)
2016-03-24
語法:
prompt(str1, str2);
參數(shù)說明:
str1: 要顯示在消息對話框中的文本,不可修改
str2:文本框中的內容,可以修改
prompt里面的第二個參數(shù)應該是網址吧