Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript Mozilla issue

Status
Not open for further replies.

scottmcgeary

Programmer
Joined
Feb 21, 2007
Messages
1
Location
US
I am stuck on this Javascript issue in Mozilla - this script works in IE6 & IE7 but not in Netscape or Mozilla - I suspect it is the "getElementById" thing but I need to know how to modify the script to get it to work correctly in Mozilla. If you e-mail me I can send you the specific URL as I don't know if it's appropriate to post here - here is the code:

<script language="javascript">
<!--
var state = 'hidden';

function showhide(layer_ref) {

if (state == 'visible') {
state = 'hidden';
}
else {
state = 'visible';
}
if (document.all) { //IS IE 4 or 5 (or 6 beta)
eval( "document.all." + layer_ref + ".style.visibility = state");
}
if (document.layers) { //IS NETSCAPE 4 or below
document.layers[layer_ref].visibility = state;
}
if (document.getElementById && !document.all) {
maxwell_smart = document.getElementById(layer_ref);
maxwell_smart.style.visibility = state;
}
}
//-->
</script>

<script>
<!-- Begin
// quick browser tests
var ns4 = (document.layers) ? true : false;
var ie4 = (document.all && !document.getElementById) ? true : false;
var ie5 = (document.all && document.getElementById) ? true : false;
var ns6 = (!document.all && document.getElementById) ? true : false;

function show(sw,obj) {
// show/hide the divisions
if (sw && (ie4 || ie5) ) document.all[obj].style.visibility = 'visible';
if (!sw && (ie4 || ie5) ) document.all[obj].style.visibility = 'hidden';
if (sw && ns4) document.layers[obj].visibility = 'visible';
if (!sw && ns4) document.layers[obj].visibility = 'hidden';
}
// End -->
</script>
<style type="text/css">
<!--
.myLayersClass { position: absolute; top: 260px; visibility: hidden; }
//-->
</style>
<script type="text/javascript">
<!--//
function state_enable(sel_value) {
var d = document.this_form;
if (sel_value == '') {
show(false,'div1');
show(false,'div2');
show(false,'div4');
show(false,'div5');
show(false,'div6');
show(false,'div7');
show(false,'div8');
show(false,'state1');
show(false,'state2');
}

}
//-->
</script>
 
If you test this in Firefox, there's a Javascript console that will show you the line and character the error where the error is.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top