简体   繁体   English

无法调用外部javascript函数

[英]Cannot call external javascript function

I cannot call the function clickie from the file fair_functions.js 我无法从文件fair_functions.js调用clickie函数

html page HTML页面

<head>

    <script type="text/javascript" src="fair_functions.js"></script>

</head>

<body>

    <button type="button" onclick="clickie();"</script>">Next</button>

</body>

fair_functions.js fair_functions.js

function clickie () {

alert("asdfsadfsdf");
window.open('test (2).html','_blank');
self.close();

} }

Try wrapping the script in the body and just before the </body> tag eg 尝试将脚本包装在正文中,并且在</body>标记之前,例如

...

<script src="fair_functions.js"></script>

</body>

</html>

Thanks everyone for your help, I just created a new file and copied in my functions one at a time and tested each time. 感谢大家的帮助,我刚刚创建了一个新文件,一次复制到函数中,并且每次都进行了测试。 It seems to be working now, not sure what happened in the old file. 现在似乎正在运行,不确定旧文件中发生了什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM