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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Friday in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

262 views 11 10
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