Is there a proper syntax that would allow a global variable assignment
to be accessed by JS and CSS and HTML?
This doesn’t work, but I’m looking to see if it’s possible.
[code=php]
<html>
<head>
<title>Global variable</title>
var CWIDE = 100; // want access to JS, CSS and HTML
var CHIGH = 100; // desire to set once and effect definitions below
<script type=”text/javascript”>
function Defaults() {
CWIDE = 100;
CHIGH = 100;
}
function LargerDefaults() {
CWIDE = 200;
CHIGH = 200;
}
function SmallerDefaults() {
CWIDE = 50;
CHIGH = 50;
}
</script>
<style type=”text/css”>
#IMGdiv {
height:CHIGH;
wide:CWIDE;
}
</style>
</head>
<body>
<div id=”IMGdiv”>
<img id=”shownIMG” src=”Picture.gif” height=CHIGH width=CWIDE>
</div>
<button onClick=”Defaults()”>Default Size</button>
<button onClick=”LargerDefaults()”>Enlarge Size</button>
<button onClick=”SmallerDefaults()”>Reduce Size</button>
</body>
</html>
I would like to set or change the first CWIDE / CHIGH values (somehow???)
and have them effect the rest of the scripts.
Is there a way to do this?