Javascript in Header

Hello, community. I found out that if I define Javascript functions in the header <head></head>, they can't be accessed in the body. What is the reason for that kind of behaviour??? Strange is also that it does work in preview but not in the saved page.

For embedding HTML and Javascript I use the HTML Macro of Confluence.

Best regards

Ewgenij

1 answer

Just include it in the body somewhere. If you must include it in the header, then wrap a function around it and then call the function in the body somewhere. Might as well just put it in the body if that is the case though.

Hello, but why is it not possible to define functions in the header like you do it usually? And as I said if I define functions in the header, I'm not able to access them in the body!

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Monday in Confluence

Calling all marketing teams who use Confluence - we want to hear from you!

Hi Community! me again 🙂 If you’re a marketing team using Confluence, we want to hear your story! How did you start using Confluence? What are your use cases? What have been some of the benefits?...

194 views 3 3
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you