Solved

html page can't find JavaScript functions

Posted on 2008-10-09
3
968 Views
Last Modified: 2013-11-19
Hi,

I'm puzzled by a problem I just started experiencing with my JavaScript (JS).  I define a number of JS functions in the head that are used for things like a calendar and operations for buttons and onclick.

I'm developing in Firefox and using the JS debugger addon which, when I click on a few of my buttons, tells me that function is not defined  e.g. "showAlert is not defined"

Except showAlert IS defined and I don't know why the page can't see it.  This is happening with most of the functions on the page, but there's one that still works, probably because it is the submit button for the page form with an onclick JS beforehand.

I've place a several alerts throughout the page body and they all fire.

How do I track down these missing function errors and find out what's happening?  

Thanks!
0
Comment
Question by:ugeb
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
hielo earned 500 total points
ID: 22681859
What you described typically happens when:
a. you give some element an id and/or name the same name that you gave the function.
b. you are assigning an anonymous function to a variabe, but the variable may be out of scope. ex:
instead of:
var myTableSorter=function(){...};

declare it as:
function myTableSorter(){...}

c. The browser may not be able to import you js files typically due to an incorrect path or a permission issue.
0
 
LVL 11

Author Closing Comment

by:ugeb
ID: 31504804
It actually had to do with a missing double quote that couldn't be seen or identified as an error in the editor for some reason.  But your comments helped me track it down, so thanks!
0
 
LVL 82

Expert Comment

by:hielo
ID: 22682120
you are welcome
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn how to count occurrences of each item in an array.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now