logo
Internet[Error Fix] Jscript Function not Defined at HTMLButtonElement.onclick

Fixed: Jscript Function not Defined at HTMLButtonElement.onclick

By Hally | Last Updated

When I used onclick="share_facebook()" on html code, I got error "Uncaught ReferenceError: share_facebook is not defined at HTMLButtonElement.onclick", as shown in the figure below.

Jscript Function not Defined at HTMLButtonElement.onclick

Here is my jscript code:

my code

All of the above function invocations are showing the same error: Uncaught ReferenceError: my_function is not defined at HTMLButtonElement.onclick.

After researching online, I was told that “function share_pinterest(){}” is written incorrectly, and that it should be written as “share_pinterest = function(){}”. But the previous way of writing “function share_pinterest(){}” is OK. I searched for a lot of ways to fix this, but it didn't work.

function share

And then it was only after a dreamweaver tip that I realized there was an error in this line of code: “function share_linkedin(){ window.open('https://www.linkedin.com/sharing/share-offsite/?url'=+document.URL,'_target','width=600,height=500,left=300px,top=150px');}”.

Later I removed this line of code and then the function invocations were working fine, so the problem was with this line of code.

Then, I changed this line of code to "function share_linkedin(){ window.open('https://www.linkedin.com/sharing/share-offsite/?url='+document.URL,'_target','width=600,height=500,left=300px,top= 150px');}", and all the function invocations are working fine.

chenge the line

Conclusion:

The reason for the problem with the function invocation is that one of the symbols in the function is written incorrectly. Correcting the symbols and the problem of “Uncaught ReferenceError: my_function is not defined at HTMLButtonElement.onclick” will be fixed.

Related Articles: