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."; } |
The button is showed but when I click it, the function didn't work.
Any help?
Thanks,
Daniel
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
Agreed!
The script executed before the component is created. document.getElementById("demo") will be return undefined
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.