在JSP中包含外部Javascript文件 - 不在Mozilla Firefox上工作 [英] Including external Javascript file in JSP- not working on Mozilla Firefox

查看:55
本文介绍了在JSP中包含外部Javascript文件 - 不在Mozilla Firefox上工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JSP页面,其中包含如下javascript文件:



I have a JSP page which includes javascript file as below:

<script type="text/javascript" src="https://siteAddress/scripts/myJsFile.js"></script>



myJsFile.js有一个方法testFireFox( )



JSP上有一个调用此方法的链接。


myJsFile.js has a method testFireFox()

There is a link on JSP which that calls this method.

<a href="#" onClick="testFireFox()">Some Text...</a>





只要点击链接,就没有了发生并且此错误出现在控制台上:< br /> 参考错误:testFirefox()未定义我尝试以各种方式提供JS文件的路径,但它没有帮助。

< br />

注意:这在Internet Explorer中运行得非常好。

任何指针都可以..



谢谢!!



As soon as i click on the link, nothing happens and this error appears on console:<br/> Refrence Error: testFirefox() is not definedI tried giving the path for JS file in various ways but it did not help.
<br/>
Note: This works absolutely fine in Internet Explorer.
any pointers pls..

Thanks!!

推荐答案

检查testFireFox()是否在
Check if the testFireFox() is inside

(文档).ready(...)



因为下面的代码工作正常



(document).ready(...)

because the below code works fine

<a href="#" onclick="testFireFox()">Some Text...</a>

<script type="text/javascript">
    function testFireFox() {
        alert('sdas');
    }
</script>





但如果加载testFireFox ()DOM准备就绪后无法正常工作



But If you load the testFireFox() after DOM is ready it isn't working

<a href="#" onclick="testFireFox()">Some Text...</a>

<script type="text/javascript">


function


这篇关于在JSP中包含外部Javascript文件 - 不在Mozilla Firefox上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆