When i am calling a javascript function , on Onclick of Button click , an error gets displayed on to Fire Bug console , displaying it as "Not a Function "
please find the scren shot attached .
The script may be defined within the contents of the SCRIPT element or in an external file. If the src attribute is not set, user agents must interpret the contents of the element as the script. If the src has a URI value, user agents must ignore the element's contents and retrieve the script via the URI.
But you can do both...
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
<script type="text/javascript">
//define here
</script>
Thanks Marc , at first i followed this approach only , but later chnaged it (Just want to say that not working either ways)
making sure that the code is properly formatted might get more people to look at it.
If its a Java Code , i would have entered Ctrl + Shift + F on Eclipse IDE to format the code , is there any way or open source plugins to format JSP / HTML Pages to format the code ??
Ravi Kiran Va wrote:... Just Replaced the onclicks function name from myButton to myButtons ...
Can't say without knowing what's in the js file. But if that's what fixed it, my guess is you've defined myButton as a global var.
For example, if you did something like this in your js file...
...and then tried to add...
...that would produce a "not a function" error (it does in Safari anyway). Changing the function name would put a bandage on the situation, but you would still have some messy code.
Again, just a guess.
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
6
posted
0
Some browsers let you reference elements by their id
so instead of
you can do [and should never do]
So it is just a name collision.
Use namespaces in your code and you will not have these issues.
Eric
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: A Javascript function is said as "Not a function"