為什么點(diǎn)擊按鈕沒反應(yīng)?(javascript入門篇2-7)
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/> ??
? <script type="text/javascript"> ?
? ??
? ? // 新窗口打開時彈出確認(rèn)框,是否打開
? ?
? ? // 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ? function openWindow(){
? ? ? ? var open=confirm("是否打開新窗口?");
? ? ? ? if(open==true){
? ? ? ? var link;
? ? ? ? link=prompt("是否要打開以下網(wǎng)址","http://idcbgp.cn");
? ? ? ? if(link!=null){
? ? ? ? ? ? window.open(link,'_blank','width=400,height=500,menubar=no,toolbar=no');
? ? ? ? }
? ? ? ? }
? ? }
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2016-08-01
confrim輸錯了
prompt里的逗號要用英文輸入法的逗號
2016-08-01
?var open=comfirm("是否打開新窗口?"); 是confirm不是comfirm,你打錯了
<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" /> 不是onclick是onClick注意區(qū)分大小寫。
?link=prompt("是否要打開以下網(wǎng)址","http://idcbgp.cn");逗號請?jiān)谟⑽妮斎敕ǖ臅r候輸入.
好了,就這樣了其實(shí)全是些小問題。下面是你的代碼改過后,是不是覺得跟你之前的長得差不多。我也舉得。
<!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 open=confirm("是否打開新窗口?");
? ? ? ? if(open==true){
? ? ? ? var link;
? ? ? ? link=prompt("是否要打開以下網(wǎng)址","http://idcbgp.cn");
? ? ? ? if(link!=null){
? ? ? ? ? ? window.open(link,'_blank','width=400,height=500,menubar=no,toolbar=no');
? ? ? ? }
? ? ? ? }
? ? }
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onClick="openWindow()" />?
?</body>
</html>
2016-08-01
function openWindow(){
? ? ? ? var mymessage=confirm("你確定要打開嗎");
? ? ? ? if(mymessage==true)
? ? ? ? {
? ? ? ? window.open('http://idcbgp.cn/','width=400,height=500,menubar=no,toolbar=no');
? ? ? ? }
? ? ? ? else
? ? ? ? {
? ? ? ? document.write("滾?。?!");
? ? }
2016-08-01
var openWindow = function(){
? ? ? ? ? ? var x =confirm("要打開新窗口嗎");
? ? ? ? ? ? if (x){
? ? ? ? ? ? ? ? var link =prompt("確定","http://idcbgp.cn/")
? ? ? ? ? ? ? ? if(link){? ? ?????????
?????????????????????????window.open(link,"_blank","width=400,height=500,menubar=no,toolbar=no")
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? };