Global Variable to effect element display

Before I get too deep in this, can someone tell me if we can interpret a variable that is outside the scope of the Hype generated js file?

The goal is to show one icon or another depending on IF there is a Global variable found on one of two pages. One page will present the Hype presentation wrapped in a pages theme (so smaller footprint) while the other page will be just the Hype presentation without being wrapped in a page theme. Depending on which page the Hype presentation finds it’s self we will display an icon that links to the other page. Basically, Expanded view (non-themed) and Contracted view (themed page).

To set the global var, I would have something like:

< script >
var whr = ‘expanded’;
< /script>
on the non-themed page.

If we place the global setting code as a wrapper to the Hype script, does that make the variable available for interpretation?

<div id="parkmap8r10generic_hype_container" style="margin:auto;position:relative;width:1140px;height:881px;overflow:hidden;">

<script type="text/javascript" charset="utf-8" > 
var whr = ('anything');</script>

	</div> (29.8 KB)

Yes, globals are fully available.

In the .hype document you posted, do note that you locally define whr as well, so this will mask the global version (resulting the if check on line 6 will always being false). You should delete line 4 of onPageLoad() if you want to use it in the manner you proposed.

Generally I always use the window.variableName notation to reinforce that it is a global.

Working… Global needs to be defined in it’s own script prior to the hype script…

Sorry I hadn’t seen close enough in your example - note that with standard HTML5, <script> tags either have a src attribute for a file (the *_hype_generated_script.js in this case) or no src and inner code. So if you want to declare a variable it needs to be in a <script> tag without a <src>.

Got it! Thanks for the continued education :slight_smile: