在這個網頁上可以打開新窗口,在本地寫的html文件打開點擊就不能打開新窗口。
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title>
? <meta? content="text/html; charset=utf-8"/>
? <script type="text/javascript">
? ? ?function openWindow(){
? ? ? ? var canshu1 =? confirm("是否打開新窗口");
? ? ? ? if(canshu1==true){
? ? ? ? ? ? var canshu2=prompt("確定要打開的窗口","http://www.baidu.com");
? ? ? ? ? ? if(canshu2!=null){
? ? ? ? ? ? ? window.open(canshu2,'_blank',
? ? ? ? ? ? ? ? 'width=600px,height=500px');
? ? ? ? ? ? }else{
? ? ? ? ? ? ? alert("打開新窗口失敗");
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? else{
? ? ? ? ? alert("取消打開新窗口");
? ? ? ? }
? ? }
? </script>
?</head>
?<body>
? ? ? <input type="button" value="新窗口打開網站" onclick="openWindow()" />
? ? ?</body>
</html>
代碼沒有問題,在這個網頁可以打開新窗口,在自己電腦本地打開就不行,請問怎么解決。
它自動在瀏覽器窗口添加了本地文件的地址,這個怎么去掉,有人知道嗎???
2019-02-20
var canshu2=prompt("確定要打開的窗口","http://
改為:
var canshu2=prompt("確定要打開的窗口","
主要是http后面的符號,要英文輸入法下
2019-02-19
網址中的那個“:”改一下應該就行了