0

Trying to implement some javascript functions within the content editor. I have more advanced code to implement, but am not able to even execute the following code. The user defined function will not execute when the link is pressed.

<script type="”text/javascript”">

function Adding(a,b) {
    alert(a+b);
}

</script>

<a href="javascript:Adding(3,4)">Click here to add two numbers</a> 

This is implemented in a Content Editor. I can implement javascript defined functions, but it will not execute a user defined function like the example above.

Any thoughts? This is on a Sharepoint 2013 Enterprise corporate intranet.

1
  • never mind ... I found my error in the <script> ... double quotes. Jun 2, 2015 at 17:34

2 Answers 2

1

Change the below code:

<a href="javascript:Adding(3,4)">Click here to add two numbers</a> 

to something like this and try:

<button onclick="javascript:Adding(3,4)">Click here to add two numbers</button> 
-3

I found the syntax error in my code.

<script type="”text/javascript”"> should be <script type="text/javascript">

2
  • 3
    This is not really an answer. Please extend it to show what was wrong and how you fixed it to make your answer as helpful as possible to future readers Jun 2, 2015 at 18:07
  • I had cut and pasted code from an example into the content editor. I don't know if it was the source, or if sharepoint modified the text (funny stuff happens in content editor as it tries to interrupt javascript). <script type=""text/javascript""> Double quotes ... you can see in my original note that they are of a different format. Jun 2, 2015 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.