Where did you install Firefox from? Help Mozilla uncover 3rd party websites that offer problematic Firefox installation by taking part in our campaign. There will be swag, and you'll be featured in our blog if you manage to report at least 10 valid reports!

Sök i support

Akta dig för supportbedrägerier: Vi kommer aldrig att be dig att ringa eller skicka ett sms till ett telefonnummer eller dela personlig information. Rapportera misstänkt aktivitet med alternativet "Rapportera missbruk".

Learn More

Firefox not calling javascript in external file

  • 1 svar
  • 4 har detta problem
  • 16 visningar
  • Senaste svar av 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.

Alla svar (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.