為什么調(diào)用輸入框的內(nèi)容無法打開網(wǎng)址?
?function openWindow(){
? ?var click=confirm("open a new window?");
? ? ? ?if(click==true)
? {
? var url=prompt("write down the url please","http://idcbgp.cn/");
? ?if(url!=null)
? ? ? {
? ? ? ? ? window.open('url','_blank','width:400px','height:500px','menubar=no','toolbar=no','scrollbars=yes');
? ? ? }
? ? ? else
? ? ? {
? ? ? ? ? alert("have fun!");
? ? ? }
? }
? else
? {
? ? ? alert("byebye!");
? }
? ?}
2016-08-23
?window.open('url','_blank','width:400px','height:500px','menubar=no','toolbar=no','scrollbars=yes');
這一行中的url是變量而不是字符串,因此不需要用單引號包裹
2016-08-23
剛剛看漏了,你后面輸入的參數(shù)格式也是有問題的。正確的格式如下:
因此你那一行的代碼應(yīng)該寫成:
希望能對你有幫助