I am a bit new to the coding. I tried to put javascript on my google site in an HTML box but it is not working. I am pasting my code here.
<!DOCTYPE html>
<html>
<body>
<p>Click the button to display an alert box:</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() {
alert("I am an alert box!");
}
</script>
</body>
</html>
It should validate with the alert box. The code is running fine when I am running it on the localhost but is not working when I am pasting it in the HTML box within a google site. my company is using Google gadget to make the HTML and javascript run over the google site. Is there any simpler way to do without google gadget?
Perhaps you shouldn't be pasting the
<html>
and<body>
tags in the widget box, as it is already part of a html document.Simply try this instead: