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!

Tìm kiếm hỗ trợ

Tránh các lừa đảo về hỗ trợ. Chúng tôi sẽ không bao giờ yêu cầu bạn gọi hoặc nhắn tin đến số điện thoại hoặc chia sẻ thông tin cá nhân. Vui lòng báo cáo hoạt động đáng ngờ bằng cách sử dụng tùy chọn "Báo cáo lạm dụng".

Learn More

Firefox not calling javascript in external file

  • 1 trả lời
  • 4 gặp vấn đề này
  • 16 lượt xem
  • Trả lời mới nhất được viết bởi 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.

Tất cả các câu trả lời (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.