我想問一下我輸入這個是什么意思?
function openWindow(){
var a=confirm("是否打開新窗口"); if(a==true)
{
var b=prompt(請輸入要打開的網(wǎng)址","http://idcbgp.cn/");
if(b!=null)
{
window.open(b,'_blank','width=400,height=500,menubar=no,toolbar=no');
}
}
}
黑體加粗的意思是什么???
function openWindow(){
var a=confirm("是否打開新窗口"); if(a==true)
{
var b=prompt(請輸入要打開的網(wǎng)址","http://idcbgp.cn/");
if(b!=null)
{
window.open(b,'_blank','width=400,height=500,menubar=no,toolbar=no');
}
}
}
黑體加粗的意思是什么???
2020-07-03
舉報
2020-07-03
如果b不為空值,就是說添加了網(wǎng)址進去,就執(zhí)行這個指令,你再補充一個else,把網(wǎng)址去掉,就能看到空值下輸出的東西
<!DOCTYPE?html>
<html>
<head>
????<title>Test</title>
????<script?type="text/javascript">
????????function?openWindow()?{
????????????var?a?=?confirm("是否打開新窗口");?
????????????if?(a?==?true)?{
????????????????var?b?=?prompt("請輸入要打開的網(wǎng)址","http://idcbgp.cn/");
????????????????if?(b?!=?null)?{
????????????????????window.open(b,?'_blank',?'width=400,height=500,menubar=no,toolbar=no');
????????????????}
????????????????else{
????????????????????document.write("呵呵");
????????????????}
????????????}
????????}
????</script>
</head>
<body>
????<input?type="button"?value="點擊按鈕"?onclick="openWindow()"?/>
</body>
</html>