這樣可以嗎
<!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 openWindow=confirm()
? ? ? ? if (openWindow==true){
? ? ? ? ? ? window.open('http://idcbgp.cn','width=400,height=500,menubar=no,toolbar=no');
? ? ? ? }
? ? ? ?else();
? ? }
2018-10-09
補充一下哈
if里面的document.write()是我測試用的,可以刪掉;
if(open!=null)改成if(open==true)
2018-10-09
if判斷語句可以不帶else 把else省略。
在confirm()和Window.open()之間少了一個prompt();
由prompt()提供一個URL(默認http://idcbgp.cn)給Window.open();
至于具體怎么補充代碼建議樓主看一下學過的教程,或者參考下我的:
?function openWindow(){
? ? ? ? var open,nurl;
? ? ? ? open=confirm("是否打開新網(wǎng)站");
? ? ? ? if(open!=null){
? ? ? ? ? ? nurl=prompt("請輸入要打開的網(wǎng)址:","http://www.baidu.com");
? ? ? ? ? ? document.write(nurl);
? ? ? ? ? ? window.open(nurl,'_blank','width=400,height=500');
? ? ? ? }
? ? }
2018-10-08
不行, else()沒有這個函數(shù),你可以試試