Skip to content
← Back to Community
HTML Button with onclick Function Not Working
Profile icon
[deleted]

I was developing a button that changed the favicon for the website. The button calls the add function.

image

When I click the button, the console pops up this error:
Screenshot 2019-10-22 at 13.25.49

It is nothing wrong with the code of the function but maybe how I am formatting it. Could somebody help and show me how?

Voters
Profile icon
CHRISTIANVALDOV
Profile icon
skmihaly05
Profile icon
SophieLaunay
Comments
hotnewtop
Profile icon
Deprincelab

not defined means that it was unable to find the javascript function to handle the onclick() method. i sudjest you check for spell error and or post the screenshort

Profile icon
Geocube101

This could be an issue with a syntax error in another part of the javascript code
(If the javascript code has an error, it will not be loaded, resulting in functions not being found)
Open your repl in a new tab and open the debug console. Click "console" form the tabs at the top. if there is an error, it will be shown in red.


The page can't seem to load your requested javascript code
Failed to load resource: the server responded with a status of 404 () favicon-notification.min.js:1

Profile icon
[deleted]

@Geocube101
There is no error until I click the button.

Profile icon
Geocube101

@hovr
on repl.it's side it shows up after you click the button, but if you open the page in a new tab (the html output) and press F+12, you should see an error

Profile icon
[deleted]

@Geocube101
It did do it.

image

Profile icon
[deleted]

It also appears to be coming from the src script in the code. How can I fix that?

image

Profile icon
mwilki7

Does an instance of the FaviconNotification object need to exist first?

Profile icon
[deleted]

@mwilki7
I don't think so. It says that the add function is not defined.