Why is my javascript rendering correctly in preview mode but stops working once the page is saved?

My code is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<title>IMG EXPAND</title>

<style type="text/css">
#ToggleTarget {
	display: none;

<script type="text/javascript">
function Toggle() {
	var el = document.getElementById("ToggleTarget");
	if (el.style.display == "block") {
		el.style.display = "none";
	else {
		el.style.display = "block";


<p><a href="javascript:Toggle();"><img src="https://thegrid.solarcity.com/download/attachments/37202190/warehouse.jpg?version=5&modificationDate=1447954817206&api=v2"/></a></p>

<div id="ToggleTarget">OMG YES<br />I DID IT I IS SO SMART</div>


1 answer

How does it look like? What does the browser logs say? Any errors?

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 Apr 13, 2018 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...

2,932 views 27 12
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