2015-04-03 45 views
0
<script> 
     function myFunction() { 
     var myWindow = window.open("http://www.w3schools.com" "width=200, height=100); 
     } 
    </script> 

<a href="terms.html" onclick="myFunction()"> Terms and Conditions</a> in this term and conditions I have an onclick that calls `myFunction()` and i justenter code here have w3school as an example 

onclick一個新的瀏覽器窗口,它必須去一個發佈的網站,也可以是一個HTML文件,我已經保存在我的hardrive叫terms.html錯誤打開使用JavaScript

回答

2

要回答您的直接問題,您應該能夠從本地計算機上的文件運行此操作。

但是,您的javascript語法錯誤。你缺少在呼叫你的參數列表一個逗號和引號,以window.open()

相反的:

var myWindow = window.open("http://www.w3schools.com" "width=200, height=100);

試試這個:

var myWindow = window.open("http://www.w3schools.com", "width=200, height=100");