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

Why is Confluence blocking execution of onclick=javascript... code within an {html} section?

Kevin Kraemer Sep 15, 2011

I have code like this:

{html}<input type=button value="Open Jira" onclick="javascript:open.window('http://jira.__.com')" /> {html}

Confluence shows the button, but when you click it, nothing happens. View Source in my browser shows the code is there. When I put this code in a plain HTML page it works. Confluence seems to be blocking it. Our administrator confirmed that all options are "enabled" for the HTML pluging. Any ideas?

Thanks,

Kevin

3 answers

1 vote
Remo Siegwart Dec 11, 2011

You need to call the open() method on the window object, not the other way around:

{html}&lt;input type=button value="Open Jira" onclick="javascript:window.open('http://jira.__.com')" /&gt; {html}

Hope this helps

Kevin Kraemer Dec 11, 2011

Oops, thanks, but in fact, that was a typo in my original post - I was actually trying window.open(), but seeing the "nothing happens" behavior. Something appears to be blocking the execution of JS.

Remo Siegwart Dec 12, 2011

What version of Confluence are you using? I tested your code in 3.5.13 and 4.0 and it worked like expected. I just had to enable the html macro of the Confluence HTML Macros plugin which should be preinstalled in Confluence. Do you have the setting "JavaScript served in header" in Confluence Admin => General Configuration enabled?

0 votes
Todd Katz Dec 10, 2011

I too would like to know how to use Javascript routines such as mouseover and onclick on Confluence pages.

0 votes
Todd Katz Dec 15, 2011

Thanks for the tips. I'd done a recent installation and, in fact, the html macros were not enabled!

So this code works for me. I'm hoping to do something with images so if I can't figure it out, I'll probably be back begging for more help :)

But in the meantime thanks for the great community support and happy holidays!

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Confluence

6 Awesome Ways to Apply Trello, JIRA and Confluence to your Project

I attended  Atlassian Summit 2019  and learned a lot from the presenters, attendees and knowledgeable Atlassian product managers. The presentations I attended focused on applying Agile, pla...

2,321 views 11 27
Read article

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