求正解 哪里錯了
? <script type="text/javascript"> ?
? ? function ?openWindow(){
? ? ? ? var han=confirm("是否打開?")
? ? ? ? if(han==true){
? ? ? ? ? ? var hanb=prompt("請輸入你要打開的網(wǎng)址")
? ? ? ? ? ? if(hanb!=null){
? ? ? ? ? ? ? ? window.open('hanb','_blank','width=400,height=500,menubar=no,toolbar=no')
? ? ? ? ? ? }
? ? ? ? ? ? else{
? ? ? ? ? ? ? ? window.open('http://widcbgp.cn/','_blank','width=400,height=500,menubar=no,toolbar=no')
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? }
? </script>?
2015-07-23
? if(hanb!=null){
? ? ? ? ? ? ? ? window.open('hanb','_blank','width=400,height=500,menubar=no,toolbar=no')
? ? ? ? ? ? }
這里改為
?if(hanb!=null){
? ? ? ? ? ? ? ? window.open(hanb,'_blank','width=400,height=500,menubar=no,toolbar=no')
? ? ? ? ? ? }
打開的URL不用單引號‘’
2015-07-27
參數(shù)中帶了引號是一個數(shù)值或者字符串,不帶引號是一個變量,在你的代碼中hanb明顯是一個變量,自然不能用引號括起來。
2015-07-23
我第一條回答是正確的,只是后來我測試時輸入的百度網(wǎng)址不完整,所以才會打開慕課網(wǎng)頁。按照上面改過來,然后輸入網(wǎng)址http://www.baidu.com/ 就可以打開百度網(wǎng)頁了
2015-07-23
輸入百度就是坑 ? ?打不開百度頁面
2015-07-23
代碼感覺沒問題,你執(zhí)行的效果不對?