Join the AMA (Ask Me Anything) with Firefox leadership team to talk about Firefox priorities in 2024. Mark your calendar! Thursday, June 13, 17:00 - 19:00 UTC.

Iskanje po podpori

Izogibajte se prevarantski tehnični podpori. Nikoli vam ne bomo naročili, da pokličete telefonsko številko ali nam pošljete osebne podatke. Sumljivo dejavnost prijavite z gumbom »Prijavi zlorabo«.

Learn More

Firefox not calling javascript in external file

  • 1 odgovor
  • 4 imajo to težavo
  • 16 ogledov
  • Zadnji odgovor od bbatl

more options

Firefox (version 22, I haven't tried this in earlier versions) cannot somehow find the reference to a .js file where my "dropdownmenu()" javascript function is located. Here is how I tested this: I created a "myalert()" function and a "dropdownmenu()" function that are both identical and look like this (just for testing purposes):

function myalert() { alert('javascript executed'); }

I put "myalert()" javascript on the aspx page itself. I put "dropdownmenu()" function in a separate .js file in the "scripts" folder. I tried the following two methods of referencing that .js script from the aspx page:

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

<script src="http://localhost/scripts/actionmenu.js" type="text/javascript"></script>

The aspx page has the two hrefs (to the two javascript functions) defined as follows:

<a href="javascript: dropdownmenu();" class="hovermenu" > My Options</a>

<a href="javascript: myalert();" class="hovermenu" > My Alert</a>

Clicking on "My Alert" works fine. So, if the javascript function is on the aspx page itself then everything works fine. Clicking on the My Options does nothing. So the javascript defined in a separate .js file does not get called.

Just to verify that I specified the correct location of the .js file, I opened the page in IE and clicked on My Options. It worked fine. It was able to find that "dropdownmenu()" function in my .js file. So the location of the .js file is definitely specified correctly but for some reason Firefox cannot find it or access it.

Firefox (version 22, I haven't tried this in earlier versions) cannot somehow find the reference to a .js file where my "dropdownmenu()" javascript function is located. Here is how I tested this: I created a "myalert()" function and a "dropdownmenu()" function that are both identical and look like this (just for testing purposes): function myalert() { alert('javascript executed'); } I put "myalert()" javascript on the aspx page itself. I put "dropdownmenu()" function in a separate .js file in the "scripts" folder. I tried the following two methods of referencing that .js script from the aspx page: <script src="scripts/actionmenu.js" type="text/javascript"></script> <script src="http://localhost/scripts/actionmenu.js" type="text/javascript"></script> The aspx page has the two hrefs (to the two javascript functions) defined as follows: <a href="javascript: dropdownmenu();" class="hovermenu" > My Options</a> <a href="javascript: myalert();" class="hovermenu" > My Alert</a> Clicking on "My Alert" works fine. So, if the javascript function is on the aspx page itself then everything works fine. Clicking on the My Options does nothing. So the javascript defined in a separate .js file does not get called. Just to verify that I specified the correct location of the .js file, I opened the page in IE and clicked on My Options. It worked fine. It was able to find that "dropdownmenu()" function in my .js file. So the location of the .js file is definitely specified correctly but for some reason Firefox cannot find it or access it.

Vsi odgovori (1)

more options

I found somebody's suggestion on a different post to try reloading the page using "Ctrl-Shirt-r" to bypass cache. Yes, after doing that, the javascript popup window showed up correctly. However, this is not really a solution since I can't tell our customers to press "Ctrl-Shift-r" each time they get to this page.