简体   繁体   English

无法通过按钮onClick事件将JavaScript集成到HTML中

[英]Trouble Integrating JavaScript into HTML with button onClick event

I have written and tested all my code in NetBeans and it works fine in the IDE. 我已经在NetBeans中编写并测试了所有代码,并且在IDE中运行良好。 When I try to integrate it into my webpage, my button onClick event does not execute. 当我尝试将其集成到网页中时,我的按钮onClick事件不执行。

I have this in my header: 我的头中有这个:

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script src="http://www.afanalytics.com/files/theme/2015.05.23_boilerUpgrade.js"></script>

I have uploaded the js file and verified that it exists in the webpage source code link. 我已经上传了js文件,并验证了它在网页源代码链接中是否存在。 However this button event does not call up the function like it does in NetBeans: 但是,此按钮事件不会像在NetBeans中那样调用该函数:

<input type="button" class="calcButton" value="Calculate" onClick="boilerUpgradeRun()">

Your external Javascript file has script tag . 您的外部Javascript文件具有script标签。 But external JS files expects only JS code without any script tag 但是外部JS文件只需要JS代码,而没有任何脚本标签

So you need to remove 所以你需要删除

<script type="text/javascript"> at the beginning

from your http://www.afanalytics.com/files/theme/2015.05.23_boilerUpgrade.js file and also remove </script> from the end 从您的http://www.afanalytics.com/files/theme/2015.05.23_boilerUpgrade.js文件中删除,也从最后删除</script>

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

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