Die Funktionalität dieser Website ist durch Wartungsarbeiten eingeschränkt, die Ihr Erlebnis verbessern sollen. Wenn ein Artikel Ihr Problem nicht löst und Sie eine Frage stellen möchten, können Sie unsere Gemeinschaft über @FirefoxSupport auf Twitter, /r/firefox oder Reddit fragen.

Hilfe durchsuchen

Vorsicht vor Support-Betrug: Wir fordern Sie niemals auf, eine Telefonnummer anzurufen, eine SMS an eine Telefonnummer zu senden oder persönliche Daten preiszugeben. Bitte melden Sie verdächtige Aktivitäten über die Funktion „Missbrauch melden“.

Weitere Informationen

Firefox not calling javascript in external file

  • 1 Antwort
  • 4 haben dieses Problem
  • 16 Aufrufe
  • Letzte Antwort von 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.

Alle Antworten (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.