onClick function works in Preview, not in Saved copy

Steven Staton
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 6, 2012

I added an anchor to a page (top of page) and the following HTML (raw) to a point further down the page:

<input type="button" onClick="window.location.href='#top'" value="Top of Page" />

When I 'preview' the page, clicking on the button takes me to the top of the page, as expected. After I 'save' the page, the button does not work. Is there something in the actual page that is blocking the Javascript action? How can I unlock this feature?

1 answer

0 votes
Remo Siegwart
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 7, 2012

It should work, you just need to reload the page after saving.

I tested it successfully with the following code:

{html}
&lt;h1 id="top"&gt;Test&lt;/h1&gt;
{html}

{loremipsum:50}

{html}
&lt;input type="button" onClick="window.location.href='#top'" value="Top of Page" /&gt;
{html}

Hope this helps

Steven Staton
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 7, 2012

Adding the 'id' to a DOM element near the top was the missing piece. Thanks!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events