Can you use onmousedown event on a Confluence page?

I'm trying to use an anmousedown event on a div on a page. It works fine in preview, but doesn't work in the regular page view -- there's no error in the JavaScript console -- it just looks like the code isn't executing.

FWIW, here's the code:

<script type="text/javascript">
function rsexpander() {
  alert("Got the click");
  var newsholediv=document.getElementById("newshole");
  var expandbar=document.getElementById('rsexpandbar');
  if (newsholediv.style.left=="0px"){
    newsholediv.style.width="25%";
    newsholediv.style.left="75%";
    expandbar.style.left="75%";
  }else{
    newsholediv.style.width="100%";
    newsholediv.style.left="0px";
    expandbar.style.left="0px";
  };
 };
</script>
 <div id="rsexpandbar" onmousedown="rsexpander()">&nbsp</div>

1 answer

1 accepted

I discovered that if I swiched to using a button and onclick instead of a div and onmousedown it worked in both peview and regular view. I also found other things that worked differently in the view and preview, in particular setting a div to display: none, which worked fine in preview and didn't work in view.

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
Published 16 hours ago in Off-topic

Get to know our Atlassian User Group Leaders from Bengaluru, India

Meet @Dinesh Dhinakaran, @Vishnu Vasudeva, @Rajeev Verma, and Jamshid Nalakath: Our extraordinary AUG leaders from Bengaluru, India. These four work together to strengthen the bonds of their local co...

115 views 0 4
Read article

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