求救啊??!為啥我怎么打都是錯(cuò)的TAT我覺得沒錯(cuò)啊!
function demo(){
? ? ? ? var first=confirm("是否發(fā)開新界面");
? ? ? ? if(first==true)
? ? {
? ? ? ? var sec=prompt("請輸入網(wǎng)址","http://imooc.com");
? ? ? ? window.open(sec,'_blank','width=400px,height=500px,menubar=no,toolbar=no');
? ? }
? ? ? ? ?else{
? ? ? ? document.write("……");
? ? }
? ? }
求指導(dǎo)!
2017-08-12
首先你的屬性 first 是一個(gè)boolean值,所以你在if中不用加入==true,輸入first本身就可以判斷了.
其次,根據(jù)題意不需要實(shí)用prompt()方法.他的作用主要是用于文本框的輸入,根據(jù)輸入文本來執(zhí)行相關(guān)操作的.你用了confirm()方法,這個(gè)方法就顯得冗余了,直接輸入頁面就好了.
還有你這個(gè)出不來,可能是沒有加www.的原因?我沒敲,你自己敲著試試