Here's a problem that's been plaguing me for weeks. I have a site that has a Flash based menu with hard coded links which are supposed to pass values to a Javascript I have in the skin file, and in turn sets the visibility of DIV elements.
Here is the Flash Actionscript for the Flash file that sits in the skin folder and is used in the skin:
homeb.onRelease = function (){
getURL(" showLayer(\'contentpane\')");
};
portfoliob.onRelease = function (){
getURL(" showLayer(\'portfolio\')");
};
contactb.onRelease = function() {
getURL(" showLayer(\'contactus\')");
};
Here is the Javascript which sits in the ascx skin file:
<script type="text/javascript" language="JavaScript">
var currentLayer = 'contentpane';
function showLayer(lyr) {
hideLayer(currentLayer);
document.getElementById(lyr).style.visibility = 'visible';
currentLayer = lyr;
}
function hideLayer(lyr) {
document.getElementById(lyr).style.visibility = 'hidden';
}
</script>
And here are the DIVs in the ascx file that are supposed to change:
<div id="contentpane" runat="server" style="visibility: visible;">
</div>
<div id="portfolio" runat="server" style="visibility: hidden;">
</div>
<div id="contactus" runat="server" style="visibility: hidden;">
</div>
It doesn't work and I'm beating my head around trying to figure it out. I tried
this in a couple of different ways and it didn't work. What is really getting me is that I did something similar on another site and it worked fine. Here's the code for that project:
function toggleVisibility(id, NNtype, IEtype, WC3type, display) {
if (document.getElementById) {
eval("document.getElementById(id).style.visibility = \"" + WC3type + "\"");
eval("document.getElementById(id).style.display = \"" + display + "\"");
} else {
if (document.layers) {
document.layers[id].visibility = NNtype;
} else {
if (document.all) {
eval("document.all." + id + ".style.visibility = \"" + IEtype + "\"");
eval("document.all." + id + ".style.display = \"" + display + "\"");
}
}
}
}
<div id="LayerName" style="visibility: hidden; display: none;" onmouseout="toggleVisibility('LayerName','hidden','hidden','hidden','none');" onmouseover="toggleVisibility('LayerName','show','visible','visible','inline');">
I tried using this Javascript instead and changing the actionscript to be the following (which didn't work either):
getURL(" toggleVisibility('portfolio','hidden','hidden','hidden','none'); toggleVisibility('contentpane','hidden','hidden','hidden','none'); toggleVisibility('contactus','show','visible','visible','inline');");
I can only conclude that the value is getting lost somewhere between Flash and the Javascript as the code worked in my other project (which didn't use Flash). Does anyone know what I'm doing wrong?