引用外部js文件和直接在html代碼中插入script標(biāo)簽有何區(qū)別?
html代碼:<input type="button" value="點(diǎn)我打開新窗口"?onclick="openWin()"/>
外部引用<script ?type="text/javascript" src="script.js"></script>
function? openWin()
{
????var sure=confirm("確定要打開新窗口嘛?");
????if(sure==true)
{
var url=prompt("請(qǐng)輸入要打開網(wǎng)頁的網(wǎng)址","http:/imooc.com/");
if(url!=null)
window.open('url','_blank','width=400px,height=500px,menubar=no,toolbar=no');
else
{
alert("再見!");
}
}
????
}
這樣的后果是出現(xiàn)404?not?found錯(cuò)誤,打不開網(wǎng)頁,但是同樣的,我把代碼拷在html代碼中就可以打開了,為什么呢?
2015-09-14
url也不要加引號(hào)
2015-09-14
逗號(hào)錯(cuò)了,應(yīng)該是英文版的逗號(hào)