function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sunnysfdcdvpsunnysfdcdvp 

A problem with the OnClick JavaScript for this button or link was encountered: syntax error

HI help me out

 

 

when i am writing javascript code in custom button it was saving correctly and code was correct.

 

but problem is when i am clicking on that particular button
 i am getting

 

A problem with the OnClick JavaScript for this button or link was encountered:  syntax error

 

please let me know

Best Answer chosen by Admin (Salesforce Developers) 
Dhaval PanchalDhaval Panchal
This is because you are writing html code, you can only write javascript code.

remove all code and just add below code.

alert("Welcome!");

and try, you will get alert on click of button.

All Answers

Dhaval PanchalDhaval Panchal
Can you please paste your code here?
sunnysfdcdvpsunnysfdcdvp


<html>
<body>

<h1>My First JavaScript</h1>

<p>
JavaScript can react to events. Like the click of a button:
</p>

<button type="button" onclick="alert('Welcome!')">Click Me!</button>

</body>
</html>

Dhaval PanchalDhaval Panchal
This is because you are writing html code, you can only write javascript code.

remove all code and just add below code.

alert("Welcome!");

and try, you will get alert on click of button.
This was selected as the best answer
sunnysfdcdvpsunnysfdcdvp

Thanks sir

 

Dhaval PanchalDhaval Panchal

Cheer !!!!