求大神指點
<html>
? ? <head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>?
? ? ? ? <script type="text/javascript">
? ? ? ? function openWindow()
? ? ? ? {
? ? ? ? ? ? var mymessage=confirm("是否打開對話框?");
? ? ? ? ? ? if(mymessage==true)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? var url=prompt("請輸入網(wǎng)址","http://idcbgp.cn");
? ? ? ? ? ? ? ? if(url!=null)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? window.open(url,"_blank",'height=500px,width=400px,menubar=no,toolbar=no');
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? alert("謝謝!");
? ? ? ? ? ? ? ? }
}
else
{
alert("謝謝");
? ? ? ? }
}
? ? ? ? </script>
? ? </head>
? ? <body>
? ? ? ? <form>
? ? ? ? ? ? <input type="button" name="botton" onclink="openWindow()" value="點擊我,打開新窗口"/>
? ? ? ? </form>
? ? </body>
</html>
求指點這里面哪里錯了
2016-10-18
2016-10-18
第一:第一個else后面括號用反了}改為{;
第二:window.open第一個屬性不能輸入網(wǎng)址變量,url1改為'idcbgp.cn';
第三:鼠標(biāo)單擊事件方法寫錯了,onclink改為onclick;
2016-10-17
? <input type="button" name="botton" onclink="openWindow()" value="點擊我,打開新窗口"/>
onclink打錯了。
然而我改了還是沒有運行出來。仿制成果,代碼:
<!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(" to imooc?");
? ? ? if (mymessage==true){
? ? ? ? var url;
? ? ? ? url=prompt("請輸入網(wǎng)址","idcbgp.cn");
? ? ? ? if(url!=null){
? ? ? ? ? ? window.open('url', '_blank','width=400,height=500,menubar=no,toolbar=no, status=no,scrollbars=yes');
? ? ? ? }
? ? ? ? else{
? ? ? ? ? ? alert("thanks!");
? ? ? ? } ??
? ? ? }
? ? ? else
? ? ? {
? ? ? ? alert("thanks!");
? ? ? }
? ? }
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
2016-10-17
? ? if(url!=null),多了感嘆號