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

CAMG Training November 19, 2015

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">
<head>
<title>IMG EXPAND</title>

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

<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";
	}
}
</script>
</head>

<body>

<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>

</body>
</html>

1 answer

0 votes
GabrielleJ
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.
November 19, 2015

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events