為什么點擊這個按鈕不彈出對話框!!程序運行不了!!
<!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 mymessage=confirm("確認打開此網(wǎng)址?");
? ? ? ? if(mymessage==true)
? ? ? ? {
? ? ? ? ? ? window.open(' http://idcbgp.cn/','width=400,height=500,menubar=no,toolbar=no');
? ? ? ? }
? ? ? ? else
? ? ? ? { ? ?
? ? ? ? } ? ?
? ? }
? ? // 新窗口打開時彈出確認框,是否打開
? ? // 通過輸入對話框,確定打開的網(wǎng)址,默認為 http://idcbgp.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ??
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
2016-03-30
var mymessage==confirm("確認打開此網(wǎng)址?");
== 改為 =
2016-03-30
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> ??
? <script type="text/javascript"> ?
? ? function openWindow(){
? ? ? ? var mychar=confirm("新窗口打開網(wǎng)站");
? ? ? ? if(mychar==true){
? ? ? ? ? ? var addr=prompt("輸入網(wǎng)址","http://idcbgp.cn/");
? ? ? ? ? ? if(addr!=null){
? ? ? ? ? ? ? ? window.open('http://idcbgp.cn/','width=400,height=500,menubar=no,toolbar=no');
? ? ? ? ? ? }? ? ? ? ?
? ? ? ? }
? ?}
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
這是最簡單的代碼:
初步看你程序錯誤有:
1:var mymessage==confirm("確認打開此網(wǎng)址?");這個地方是一個=號,是賦值語句;而==是邏輯表達式;
2:根據(jù)題目缺少prompt()函數(shù)。
2016-03-30
? var mymessage==confirm("確認打開此網(wǎng)址?");這個地方是一個=號
2016-03-30
var mymessage==confirm("確認打開此網(wǎng)址?");? 你寫的雙等號,正確的為單等號。
2016-03-30
這是我寫的代碼
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> ??
? <script type="text/javascript"> ?
? ? function openWindow(){
? ? ? ? var name=confirm("新窗口打開網(wǎng)站");
? ? ? ? if(name==true){
? ? ? ? ? ? var add=prompt("輸入網(wǎng)址","http://idcbgp.cn/");
? ? ? ? ? ? if(add!=null){
? ? ? ? ? ? ? ? window.open('http://idcbgp.cn/','width=400,height=500,menubar=no,toolbar=no');
? ? ? ? ? ? }
? ? ? ? ? ? else{
? ? ? ? ? ? ? ?window.open();?
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? else{
? ? ? ? ? ??
? ? ? ? }
? ? }
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>