<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
它必须去一个公开的网站还是它可以是我保存在hardrive中的html文件terms.html
?
要回答您的直接问题,您应该能够从本地计算机上的文件中运行它。
但是,您的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");
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句