It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Simple javascript in HTML macro : Confluence

Hello,

I tried to run very simple javascript inside HTML macro in Confluence page.

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">

	function myFunction() {
  	document.getElementById("demo").innerHTML = "Paragraph changed.";
	}
</script> </head> <body> <h2>JavaScript in Head</h2> <p id="demo">A Paragraph.</p> <button type="button" id="buttonId" onclick="myFunction()">Try it</button> </body> </html>

 

The button is showed but when I click it, the function didn't work.

Any help?

 

Thanks,

Daniel

1 answer

1 accepted

0 votes
Answer accepted

Hi Daniel,

Could you try to change the order like this?

 

<!DOCTYPE html>
<html>
<head>

</head>
<body>
                <h2>JavaScript in Head</h2>

    <p id="demo">A Paragraph.</p>

    <button type="button" id="buttonId" onclick="myFunction()">Try it</button>

<script type="text/javascript"> function myFunction() { document.getElementById("demo").innerHTML = "Paragraph changed."; }
</script>
</body> </html>

 

 

Regards

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

275 views 1 2
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you