I'm having a problem using different properties of the document object
in the example javascripts in my textbook with browsers that identify
themselves as using the Mozilla engine. One example of these
problems is using document.layers . I have Google'd for examples of how
to use the document object specifically with Mozilla, but I cannot
find anything that explains why my problems occur. Could anyone here
see through the included example and tell me if there is anything
absolutely wrong with this?
It seems to me that the examples in my textbook simplify browser
identification to the point where it doesn't work. Am I right in this?
----------example----------
<html>
<head>
<meta name="keywords" content="">
<meta name="descripti on" content="">
<title>Test-titel</title>
<link rel="stylesheet " href="./style.css">
<script language="javas cript">
<!--
var active = 0;
var browser = null;
function Init()
{
browser = new BrowserObj();
}
function BrowserObj()
{
this.navigator = null;
this.explorer = null;
this.other = null;
if((navigator.a ppName.toLowerC ase()).
indexOf("netsca pe") >= 0)
this.navigator = 1;
else
if((navigator.a ppName.toLowerC ase()).indexOf( "explorer") >= 0)
this.explorer = 1;
else
this.other = 1;
this.major = parseInt(naviga tor.appVersion) ;
this.minor = parseFloat(navi gator.appVersio n);
}
function ChangeLayer(now )
{
if(browser.navi gator != null)
{
document.layers["content" + active].visibility = "hide";
document.layers["content" + now].visibility = "show";
}
else
{
var current = document.all("c ontent" + active).style;
var next = document.all("c ontent" + now).style;
current.visibil ity = "hidden";
next.visibility = "visible";
active = now;
}
}
// -->
</script>
</head>
<body onLoad="Init()" >
<div id="menua" style="top: 5; left: 5; visibility: visible;
position: absolute; z-index: 5;">
<p class="SWITCH">
<a href="#" onClick="Change Layer(0)">One</a>
<a href="#" onClick="Change Layer(1)">Two</a>
<a href="#" onClick="Change Layer(2)">Three </a>
</p>
</div>
<div id="content0" style="top: 40; left: 0; visibility: visible;
position: absolute;">
<h1>A test header</h1>
<p>Here is some text</p>
</div>
<div id="content1" style="top: 40; left: 0; visibility: visible;
position: absolute;">
<h1>One more test header</h1>
<p>Some more test</p>
</div>
<div id="content2" style="top: 40; left: 0; visibility: visible;
position: absolute;">
<h1>Yet one more test header</h1>
<p>Yet more text</p>
</div>
</body>
</html>
----------example----------
--
Med venlig hilsen / Best regards
David List
in the example javascripts in my textbook with browsers that identify
themselves as using the Mozilla engine. One example of these
problems is using document.layers . I have Google'd for examples of how
to use the document object specifically with Mozilla, but I cannot
find anything that explains why my problems occur. Could anyone here
see through the included example and tell me if there is anything
absolutely wrong with this?
It seems to me that the examples in my textbook simplify browser
identification to the point where it doesn't work. Am I right in this?
----------example----------
<html>
<head>
<meta name="keywords" content="">
<meta name="descripti on" content="">
<title>Test-titel</title>
<link rel="stylesheet " href="./style.css">
<script language="javas cript">
<!--
var active = 0;
var browser = null;
function Init()
{
browser = new BrowserObj();
}
function BrowserObj()
{
this.navigator = null;
this.explorer = null;
this.other = null;
if((navigator.a ppName.toLowerC ase()).
indexOf("netsca pe") >= 0)
this.navigator = 1;
else
if((navigator.a ppName.toLowerC ase()).indexOf( "explorer") >= 0)
this.explorer = 1;
else
this.other = 1;
this.major = parseInt(naviga tor.appVersion) ;
this.minor = parseFloat(navi gator.appVersio n);
}
function ChangeLayer(now )
{
if(browser.navi gator != null)
{
document.layers["content" + active].visibility = "hide";
document.layers["content" + now].visibility = "show";
}
else
{
var current = document.all("c ontent" + active).style;
var next = document.all("c ontent" + now).style;
current.visibil ity = "hidden";
next.visibility = "visible";
active = now;
}
}
// -->
</script>
</head>
<body onLoad="Init()" >
<div id="menua" style="top: 5; left: 5; visibility: visible;
position: absolute; z-index: 5;">
<p class="SWITCH">
<a href="#" onClick="Change Layer(0)">One</a>
<a href="#" onClick="Change Layer(1)">Two</a>
<a href="#" onClick="Change Layer(2)">Three </a>
</p>
</div>
<div id="content0" style="top: 40; left: 0; visibility: visible;
position: absolute;">
<h1>A test header</h1>
<p>Here is some text</p>
</div>
<div id="content1" style="top: 40; left: 0; visibility: visible;
position: absolute;">
<h1>One more test header</h1>
<p>Some more test</p>
</div>
<div id="content2" style="top: 40; left: 0; visibility: visible;
position: absolute;">
<h1>Yet one more test header</h1>
<p>Yet more text</p>
</div>
</body>
</html>
----------example----------
--
Med venlig hilsen / Best regards
David List
Comment