Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a JSP page which includes javascript file as below:

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

myJsFile.js has a method testFireFox()

There is a link on JSP which that calls this method.
C#
<a href="#" onClick="testFireFox()">Some Text...</a>


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!!
Posted
Updated 9-Feb-15 22:25pm
v2
Comments
Kornfeld Eliyahu Peter 10-Feb-15 4:24am    
Firefox has a very powerful debugger - try use it to figure out what preventing the download of the js file...(look at the console massages upon page load)

1 solution

Check if the testFireFox() is inside $(document).ready(...)

because the below code works fine

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

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


But If you load the testFireFox() after DOM is ready it isn't working
HTML
<a href="#" onclick="testFireFox()">Some Text...</a>

<script type="text/javascript">
    $(function ($) {
        function testFireFox() {
            alert('sdas');
        }
    });
</script>
 
Share this answer
 
Comments
Techie12 12-Feb-15 5:27am    
no testFirefox() is not inside document.ready, i'am not using jquery anywhere and onload="" for the form, scrits are included directly in <head>, Any other suggestions? Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900