Sanjiv Rajiv
asked on
getElementById function Probelm
I have code problem
when you click any topic from this code it show all the topic
It should show
Topic 1 for Topic 1
Topic 2 for topic 2
and so on
so if user click twice on Topic 1 is should popup only Topic 1
NOT 2,3,4,5
Here is the code
Do not give me new code because this works on NE 4 and NE 6 and IE so i don't want new code
Thanks
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#CCCCCC" text="#000000">
<td bgcolor=#003366 valign=bottom width=589>
<table border=1 cellspacing=1 cellpadding=5 width="497">
<tr> <td><a style="cursor:hand" onClick="altercontent(1)" href="#no"> Topic 1</a> <a style="cursor:hand" onClick="altercontent(2)" href="#no">Topic 2</a> <a style="cursor:hand" onClick="altercontent(3)" href="#no">Topic 3</a> <a style="cursor:hand" onClick="altercontent(4)" href="#no">Topic 4</a> <a style="cursor:hand" onClick="altercontent(5)" href="#no">Topic 5</a></td></tr>
</table>
<div id="dcontent" style="width:589px;height: 28px"></di v>
<ilayer id="ns4dcontent" width=589px height=28px left="-1">
<layer id="ns4dcontent2" width=589px height=28px></layer></ilay er>
<script>
//the html contents to display
var mycontent=new Array()
mycontent[0]='Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>'
mycontent[1]='Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>'
mycontent[2]='Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>'
mycontent[3]='Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>'
mycontent[4]='Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>'
var i=0
function altercontent(){
//if IE 4+
if (document.all)
dcontent.innerHTML=myconte nt[i];
//else if NS 4
else if (document.layers){
document.ns4dcontent.docum ent.ns4dco ntent2.
document.write(mycontent[i ]);
document.ns4dcontent.docum ent.ns4dco ntent2.
document.close();
}
//else if NS 6 (supports new DOM)
else if (document.getElementById){
rng = document.createRange();
el = document.getElementById("d content");
rng.setStartBefore(el);
htmlFrag = rng.createContextualFragme nt(myconte nt[i]);
while (el.hasChildNodes())
el.removeChild(el.lastChil d);
el.appendChild(htmlFrag);
}
if (i==mycontent.length-1)
i=0
else
i++
}
function beginrotation(){
if (document.all||document.la yers||docu ment.getEl ementById)
setInterval("altercontent( )")
}
window.onload=beginrotatio n
</script>
<p> </p></td>
</body>
</html>
when you click any topic from this code it show all the topic
It should show
Topic 1 for Topic 1
Topic 2 for topic 2
and so on
so if user click twice on Topic 1 is should popup only Topic 1
NOT 2,3,4,5
Here is the code
Do not give me new code because this works on NE 4 and NE 6 and IE so i don't want new code
Thanks
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#CCCCCC" text="#000000">
<td bgcolor=#003366 valign=bottom width=589>
<table border=1 cellspacing=1 cellpadding=5 width="497">
<tr> <td><a style="cursor:hand" onClick="altercontent(1)" href="#no"> Topic 1</a> <a
</table>
<div id="dcontent" style="width:589px;height:
<ilayer id="ns4dcontent" width=589px height=28px left="-1">
<layer id="ns4dcontent2" width=589px height=28px></layer></ilay
<script>
//the html contents to display
var mycontent=new Array()
mycontent[0]='Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>'
mycontent[1]='Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>'
mycontent[2]='Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>'
mycontent[3]='Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>'
mycontent[4]='Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>'
var i=0
function altercontent(){
//if IE 4+
if (document.all)
dcontent.innerHTML=myconte
//else if NS 4
else if (document.layers){
document.ns4dcontent.docum
document.write(mycontent[i
document.ns4dcontent.docum
document.close();
}
//else if NS 6 (supports new DOM)
else if (document.getElementById){
rng = document.createRange();
el = document.getElementById("d
rng.setStartBefore(el);
htmlFrag = rng.createContextualFragme
while (el.hasChildNodes())
el.removeChild(el.lastChil
el.appendChild(htmlFrag);
}
if (i==mycontent.length-1)
i=0
else
i++
}
function beginrotation(){
if (document.all||document.la
setInterval("altercontent(
}
window.onload=beginrotatio
</script>
<p> </p></td>
</body>
</html>
ASKER
niteshn,
This is good but
I need to have expanding on NE 4 and NE 6
If you copy this code and look in IE you will see that it's expanding in IE that (yellow tabel)
but In NE 4 and NE 6 it's not expanding
help me please
here is the code
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#CCCCCC" text="#000000">
<td bgcolor=#003366 valign=bottom width=589>
<table border=1 cellspacing=1 cellpadding=5 width="497">
<tr> <td><a style="cursor:hand" onClick="altercontent(1)" href="#no"> Topic 1</a> <a style="cursor:hand" onClick="altercontent(2)" href="#no">Topic 2</a> <a style="cursor:hand" onClick="altercontent(3)" href="#no">Topic 3</a> <a style="cursor:hand" onClick="altercontent(4)" href="#no">Topic 4</a> <a style="cursor:hand" onClick="altercontent(5)" href="#no">Topic 5</a></td></tr>
</table>
<div id="dcontent" style="width:589px;height: 28px"></di v>
<ilayer id="ns4dcontent" width=589px height=28px>
<layer id="ns4dcontent2" width=589px height=28px></layer></ilay er>
<script>
//the html contents to display
var mycontent=new Array()
mycontent[1]='Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>'
mycontent[2]='Topic 2<br>2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>'
mycontent[3]='Topic 3<br>Topic 3Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>'
mycontent[4]='Topic 4<br>ic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>'
mycontent[5]='Topic 5<br>Topic 5<br>T5<br>Topic 5<br>Topic 5<br>Topic 5<br>5<br>'
function altercontent(i){
//if IE 4+
if (document.all)
dcontent.innerHTML=myconte nt[i];
//else if NS 4
else if (document.layers){
document.ns4dcontent.docum ent.ns4dco ntent2.
document.write(mycontent[i ]);
document.ns4dcontent.docum ent.ns4dco ntent2.
document.close();
}
//else if NS 6 (supports new DOM)
else if (document.getElementById){
rng = document.createRange();
el = document.getElementById("d content");
rng.setStartBefore(el);
htmlFrag = rng.createContextualFragme nt(myconte nt[i]);
while (el.hasChildNodes())
el.removeChild(el.lastChil d);
el.appendChild(htmlFrag);
}
}
function beginrotation(){
if (document.all||document.la yers||docu ment.getEl ementById)
setInterval("altercontent( 1)")
}
window.onload=beginrotatio n
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFF66">
<tr><td>This is Expanding in IE <br> Not expanding on NE 4 and 6 Need to have expanding </td></tr>
</table>
<p> </p></td>
</body>
</html>
This is good but
I need to have expanding on NE 4 and NE 6
If you copy this code and look in IE you will see that it's expanding in IE that (yellow tabel)
but In NE 4 and NE 6 it's not expanding
help me please
here is the code
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#CCCCCC" text="#000000">
<td bgcolor=#003366 valign=bottom width=589>
<table border=1 cellspacing=1 cellpadding=5 width="497">
<tr> <td><a style="cursor:hand" onClick="altercontent(1)" href="#no"> Topic 1</a> <a
</table>
<div id="dcontent" style="width:589px;height:
<ilayer id="ns4dcontent" width=589px height=28px>
<layer id="ns4dcontent2" width=589px height=28px></layer></ilay
<script>
//the html contents to display
var mycontent=new Array()
mycontent[1]='Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>'
mycontent[2]='Topic 2<br>2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>'
mycontent[3]='Topic 3<br>Topic 3Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>'
mycontent[4]='Topic 4<br>ic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>'
mycontent[5]='Topic 5<br>Topic 5<br>T5<br>Topic 5<br>Topic 5<br>Topic 5<br>5<br>'
function altercontent(i){
//if IE 4+
if (document.all)
dcontent.innerHTML=myconte
//else if NS 4
else if (document.layers){
document.ns4dcontent.docum
document.write(mycontent[i
document.ns4dcontent.docum
document.close();
}
//else if NS 6 (supports new DOM)
else if (document.getElementById){
rng = document.createRange();
el = document.getElementById("d
rng.setStartBefore(el);
htmlFrag = rng.createContextualFragme
while (el.hasChildNodes())
el.removeChild(el.lastChil
el.appendChild(htmlFrag);
}
}
function beginrotation(){
if (document.all||document.la
setInterval("altercontent(
}
window.onload=beginrotatio
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFF66">
<tr><td>This is Expanding in IE <br> Not expanding on NE 4 and 6 Need to have expanding </td></tr>
</table>
<p> </p></td>
</body>
</html>
Try this... Though the ilayer content is still cut off in NS4
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#CCCCCC" text="#000000">
<td bgcolor=#003366 valign=bottom width=589>
<table border=0 cellspacing=1 cellpadding=5 width="497">
<tr><td ><a style="cursor:hand" onClick="altercontent(1)" href="#no"> Topic 1</a> <a style="cursor:hand" onClick="altercontent(2)" href="#no">Topic 2</a> <a style="cursor:hand" onClick="altercontent(3)" href="#no">Topic 3</a> <a style="cursor:hand" onClick="altercontent(4)" href="#no">Topic 4</a> <a style="cursor:hand" onClick="altercontent(5)" href="#no">Topic 5</a></td></tr>
<tr> <td>
<div id="dcontent" style="width:589px;height: 28px"></di v>
<ilayer id="ns4dcontent" width=589px height=28px>
<layer id="ns4dcontent2" width=589px height=28px></layer></ilay er>
</td></tr>
<script>
//the html contents to display
var mycontent=new Array()
mycontent[1]='Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>'
mycontent[2]='Topic 2<br>2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>'
mycontent[3]='Topic 3<br>Topic 3Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>'
mycontent[4]='Topic 4<br>ic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>'
mycontent[5]='Topic 5<br>Topic 5<br>T5<br>Topic 5<br>Topic 5<br>Topic 5<br>5<br>'
function altercontent(i){
//if IE 4+
if (document.all)
dcontent.innerHTML=myconte nt[i];
//else if NS 4
else if (document.layers){
document.ns4dcontent.docum ent.ns4dco ntent2.
document.write(mycontent[i ]);
document.ns4dcontent.docum ent.ns4dco ntent2.
document.close();
}
//else if NS 6 (supports new DOM)
else if (document.getElementById){
rng = document.createRange();
el = document.getElementById("d content");
rng.setStartBefore(el);
htmlFrag = rng.createContextualFragme nt(myconte nt[i]);
while (el.hasChildNodes())
el.removeChild(el.lastChil d);
el.appendChild(htmlFrag);
}
}
function beginrotation(){
if (document.all||document.la yers||docu ment.getEl ementById)
setInterval("altercontent( 1)")
}
window.onload=beginrotatio n
</script>
<tr><td bgcolor="#FFFF66">This is Expanding in IE <br> Not expanding on NE 4 and 6 Need to have expanding </td></tr>
</table>
<p> </p></td>
</body>
</html>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#CCCCCC" text="#000000">
<td bgcolor=#003366 valign=bottom width=589>
<table border=0 cellspacing=1 cellpadding=5 width="497">
<tr><td ><a style="cursor:hand" onClick="altercontent(1)" href="#no"> Topic 1</a> <a
<tr> <td>
<div id="dcontent" style="width:589px;height:
<ilayer id="ns4dcontent" width=589px height=28px>
<layer id="ns4dcontent2" width=589px height=28px></layer></ilay
</td></tr>
<script>
//the html contents to display
var mycontent=new Array()
mycontent[1]='Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>'
mycontent[2]='Topic 2<br>2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>'
mycontent[3]='Topic 3<br>Topic 3Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>'
mycontent[4]='Topic 4<br>ic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>'
mycontent[5]='Topic 5<br>Topic 5<br>T5<br>Topic 5<br>Topic 5<br>Topic 5<br>5<br>'
function altercontent(i){
//if IE 4+
if (document.all)
dcontent.innerHTML=myconte
//else if NS 4
else if (document.layers){
document.ns4dcontent.docum
document.write(mycontent[i
document.ns4dcontent.docum
document.close();
}
//else if NS 6 (supports new DOM)
else if (document.getElementById){
rng = document.createRange();
el = document.getElementById("d
rng.setStartBefore(el);
htmlFrag = rng.createContextualFragme
while (el.hasChildNodes())
el.removeChild(el.lastChil
el.appendChild(htmlFrag);
}
}
function beginrotation(){
if (document.all||document.la
setInterval("altercontent(
}
window.onload=beginrotatio
</script>
<tr><td bgcolor="#FFFF66">This is Expanding in IE <br> Not expanding on NE 4 and 6 Need to have expanding </td></tr>
</table>
<p> </p></td>
</body>
</html>
Try this... Though the ilayer content is still cut off in NS4
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#CCCCCC" text="#000000">
<td bgcolor=#003366 valign=bottom width=589>
<table border=0 cellspacing=1 cellpadding=5 width="497">
<tr><td ><a style="cursor:hand" onClick="altercontent(1)" href="#no"> Topic 1</a> <a style="cursor:hand" onClick="altercontent(2)" href="#no">Topic 2</a> <a style="cursor:hand" onClick="altercontent(3)" href="#no">Topic 3</a> <a style="cursor:hand" onClick="altercontent(4)" href="#no">Topic 4</a> <a style="cursor:hand" onClick="altercontent(5)" href="#no">Topic 5</a></td></tr>
<tr> <td>
<div id="dcontent" style="width:589px;height: 28px"></di v>
<ilayer id="ns4dcontent" width=589px height=28px>
<layer id="ns4dcontent2" width=589px height=28px></layer></ilay er>
</td></tr>
<script>
//the html contents to display
var mycontent=new Array()
mycontent[1]='Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>'
mycontent[2]='Topic 2<br>2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>'
mycontent[3]='Topic 3<br>Topic 3Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>'
mycontent[4]='Topic 4<br>ic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>'
mycontent[5]='Topic 5<br>Topic 5<br>T5<br>Topic 5<br>Topic 5<br>Topic 5<br>5<br>'
function altercontent(i){
//if IE 4+
if (document.all)
dcontent.innerHTML=myconte nt[i];
//else if NS 4
else if (document.layers){
document.ns4dcontent.docum ent.ns4dco ntent2.
document.write(mycontent[i ]);
document.ns4dcontent.docum ent.ns4dco ntent2.
document.close();
}
//else if NS 6 (supports new DOM)
else if (document.getElementById){
rng = document.createRange();
el = document.getElementById("d content");
rng.setStartBefore(el);
htmlFrag = rng.createContextualFragme nt(myconte nt[i]);
while (el.hasChildNodes())
el.removeChild(el.lastChil d);
el.appendChild(htmlFrag);
}
}
function beginrotation(){
if (document.all||document.la yers||docu ment.getEl ementById)
setInterval("altercontent( 1)")
}
window.onload=beginrotatio n
</script>
<tr><td bgcolor="#FFFF66">This is Expanding in IE <br> Not expanding on NE 4 and 6 Need to have expanding </td></tr>
</table>
<p> </p></td>
</body>
</html>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#CCCCCC" text="#000000">
<td bgcolor=#003366 valign=bottom width=589>
<table border=0 cellspacing=1 cellpadding=5 width="497">
<tr><td ><a style="cursor:hand" onClick="altercontent(1)" href="#no"> Topic 1</a> <a
<tr> <td>
<div id="dcontent" style="width:589px;height:
<ilayer id="ns4dcontent" width=589px height=28px>
<layer id="ns4dcontent2" width=589px height=28px></layer></ilay
</td></tr>
<script>
//the html contents to display
var mycontent=new Array()
mycontent[1]='Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>'
mycontent[2]='Topic 2<br>2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>'
mycontent[3]='Topic 3<br>Topic 3Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>'
mycontent[4]='Topic 4<br>ic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>'
mycontent[5]='Topic 5<br>Topic 5<br>T5<br>Topic 5<br>Topic 5<br>Topic 5<br>5<br>'
function altercontent(i){
//if IE 4+
if (document.all)
dcontent.innerHTML=myconte
//else if NS 4
else if (document.layers){
document.ns4dcontent.docum
document.write(mycontent[i
document.ns4dcontent.docum
document.close();
}
//else if NS 6 (supports new DOM)
else if (document.getElementById){
rng = document.createRange();
el = document.getElementById("d
rng.setStartBefore(el);
htmlFrag = rng.createContextualFragme
while (el.hasChildNodes())
el.removeChild(el.lastChil
el.appendChild(htmlFrag);
}
}
function beginrotation(){
if (document.all||document.la
setInterval("altercontent(
}
window.onload=beginrotatio
</script>
<tr><td bgcolor="#FFFF66">This is Expanding in IE <br> Not expanding on NE 4 and 6 Need to have expanding </td></tr>
</table>
<p> </p></td>
</body>
</html>
ASKER
niteshn ,
Can you hide and not show in NE 4 ?
And that's all you get 250
Please
Thnaks
Can you hide and not show in NE 4 ?
And that's all you get 250
Please
Thnaks
This should work better for you...
You don't need the extra CSS on the <A ...>
The hand is automatically the cursor links.
And you can make the href a javascript function as shown above... You were passing the value of the topic into the function, but not using the paramater in the function...
adding the href="#no" sometimes caused the text to disappear.
This works good in IE and NS 4.7, didn't test it in NS 6+.
<html>
<body bgcolor="#CCCCCC" text="#000000">
<script language="javascript">
//the html contents to display
var mycontent=new Array();
mycontent[1]='Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>';
mycontent[2]='Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>';
mycontent[3]='Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>';
mycontent[4]='Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>';
mycontent[5]='Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>';
function altercontent(i){
//if IE 4+
if (document.all)
dcontent.innerHTML=myconte nt[i];
//else if NS 4
else if (document.layers){
document.ns4dcontent.docum ent.ns4dco ntent2.
document.write(mycontent[i ]);
document.ns4dcontent.docum ent.ns4dco ntent2.
document.close();
}else if (document.getElementById){ //else if NS 6 (supports new DOM)
rng = document.createRange();
el = document.getElementById("d content");
el.innerHtml = 'crap';
rng.setStartBefore(el);
htmlFrag = rng.createContextualFragme nt(myconte nt[i]);
}
else ;
}
</script>
<table border=1 cellspacing=1 cellpadding=5 width="497">
<tr><td><a href="javascript:altercont ent(1)" > Topic 1</a> <a href="javascript:altercont ent(2)">To pic 2</a> <a href="javascript:altercont ent(3)">To pic 3</a> <a href="javascript:altercont ent(4)">To pic 4</a> <a href="javascript:altercont ent(5)">To pic 5</a></td></tr>
</table>
<div id="dcontent" style="width:589px;height: 28px"></di v>
<ilayer id="ns4dcontent" width=589px height=28px left="-1">
<layer id="ns4dcontent2" width=589px height=28px></layer>
</ilayer>
</body>
</html>
You don't need the extra CSS on the <A ...>
The hand is automatically the cursor links.
And you can make the href a javascript function as shown above... You were passing the value of the topic into the function, but not using the paramater in the function...
adding the href="#no" sometimes caused the text to disappear.
This works good in IE and NS 4.7, didn't test it in NS 6+.
<html>
<body bgcolor="#CCCCCC" text="#000000">
<script language="javascript">
//the html contents to display
var mycontent=new Array();
mycontent[1]='Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>';
mycontent[2]='Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>';
mycontent[3]='Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>';
mycontent[4]='Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>';
mycontent[5]='Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>';
function altercontent(i){
//if IE 4+
if (document.all)
dcontent.innerHTML=myconte
//else if NS 4
else if (document.layers){
document.ns4dcontent.docum
document.write(mycontent[i
document.ns4dcontent.docum
document.close();
}else if (document.getElementById){
rng = document.createRange();
el = document.getElementById("d
el.innerHtml = 'crap';
rng.setStartBefore(el);
htmlFrag = rng.createContextualFragme
}
else ;
}
</script>
<table border=1 cellspacing=1 cellpadding=5 width="497">
<tr><td><a href="javascript:altercont
</table>
<div id="dcontent" style="width:589px;height:
<ilayer id="ns4dcontent" width=589px height=28px left="-1">
<layer id="ns4dcontent2" width=589px height=28px></layer>
</ilayer>
</body>
</html>
You don't really need to hide it all in NS4. you can probably set the height of the layer. If you still need to disable the whole page for NS4 you can try
<head>
<script language="javascript">
if(navigator.appName=="Net scape" && document.layers)
{
alert("This page doesnot work with Netscape 4.X- versions")
window.location = "alternativepageforns4.htm l"
}
</script>
</head>
<body>
...
Else if you just need to stop this function in NS4 just remove this portion from your code...
//else if NS 4
else if (document.layers){
document.ns4dcontent.docum ent.ns4dco ntent2.
document.write(mycontent[i ]);
document.ns4dcontent.docum ent.ns4dco ntent2.
document.close();
}
<head>
<script language="javascript">
if(navigator.appName=="Net
{
alert("This page doesnot work with Netscape 4.X- versions")
window.location = "alternativepageforns4.htm
}
</script>
</head>
<body>
...
Else if you just need to stop this function in NS4 just remove this portion from your code...
//else if NS 4
else if (document.layers){
document.ns4dcontent.docum
document.write(mycontent[i
document.ns4dcontent.docum
document.close();
}
ASKER
niteshn
When i remove this i get error on IE
Else if you just need to stop this function in NS4 just remove this portion from your code...
//else if NS 4
else if (document.layers){
document.ns4dcontent.docum ent.ns4dco ntent2.
document.write(mycontent[i ]);
document.ns4dcontent.docum ent.ns4dco ntent2.
document.close();
}
I want to make it work like what this site has it
http://www.attbi.com
Top News businss and sports in center
If you could make this work in all IE and NE 4+
I can live with different approch as long as it works
If you need more points i can do that to 1000 points or 1500 points
Thanks
When i remove this i get error on IE
Else if you just need to stop this function in NS4 just remove this portion from your code...
//else if NS 4
else if (document.layers){
document.ns4dcontent.docum
document.write(mycontent[i
document.ns4dcontent.docum
document.close();
}
I want to make it work like what this site has it
http://www.attbi.com
Top News businss and sports in center
If you could make this work in all IE and NE 4+
I can live with different approch as long as it works
If you need more points i can do that to 1000 points or 1500 points
Thanks
Try mine.
ASKER
a1programmer,
Problem with NE 6 with your code
I want to make it work like what this site has it
http://www.attbi.com
Top News businss and sports in center
If you could make this work in all IE and NE 4+
I can live with different approch as long as it works
If you need more points i can do that to 1000 points or 1500 points
Thanks
Problem with NE 6 with your code
I want to make it work like what this site has it
http://www.attbi.com
Top News businss and sports in center
If you could make this work in all IE and NE 4+
I can live with different approch as long as it works
If you need more points i can do that to 1000 points or 1500 points
Thanks
You can see that here the height of the content is consistant. You'll have to specify the height of the layer in that case for NS4. For other browsers it'll work fine. Instead of 28px as specified now you should specify the height so as the content fills in fine.
You can see that in case of attbi site the height of the content for each menu item is consistant. You'll have to specify the height of the layer in that case for NS4. For other browsers it'll work fine. Instead of 28px as specified now you should specify the height so as the content fills in fine. ie it should be like
<ilayer id="ns4dcontent" width=589px height=200px left="-1">
<layer id="ns4dcontent2" width=589px height=200px></layer>
</ilayer>
height needs to be increased accroding to the height of the content text you have.
<ilayer id="ns4dcontent" width=589px height=200px left="-1">
<layer id="ns4dcontent2" width=589px height=200px></layer>
</ilayer>
height needs to be increased accroding to the height of the content text you have.
ASKER
niteshn,
Yes I can have the Ilayer hight 200px
But the probelm i am runnig into is
why this is not expanding in NE 4
if you put tabel after </ilayer>
<table width="100" border="0" cellspacing="0" cellpadding="0" bgcolor="#CCFF66">
<tr><td>&test test test tese </td></tr>
and see in NE 4
Yes I can have the Ilayer hight 200px
But the probelm i am runnig into is
why this is not expanding in NE 4
if you put tabel after </ilayer>
<table width="100" border="0" cellspacing="0" cellpadding="0" bgcolor="#CCFF66">
<tr><td>&test test test tese </td></tr>
and see in NE 4
Your going to have limitations with making it compatible with all brosers..
NS will not shift some things down when other things expand... The site you gave us as an example demonstrates this perfectly, but there is no dynamic sizing...
NS will not shift some things down when other things expand... The site you gave us as an example demonstrates this perfectly, but there is no dynamic sizing...
The auto expand/collapse that happens in IE ans NS6+ will not happen in NS4. It is the default behaviour in the browser that once a layer height is fixed it doesn't change automatically. So if the content is more than the height it is truncated. That is why i suggested thagt you fix the height of the ilayer so that it contains the max content. height of 15px is sufficient for the eg. here. This would eb something you'll have to live with.
The other option would be to change the height of the layer each time you put the content. For this you'll have you estimate a prospective height for each topic and change it using...
document.ns4dcontent.heigh t = "100px"
document.ns4dcontent.docum ent.ns4dco ntent2.hei ght="100px "
etc...
The other option would be to change the height of the layer each time you put the content. For this you'll have you estimate a prospective height for each topic and change it using...
document.ns4dcontent.heigh
document.ns4dcontent.docum
etc...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I meant browsers, not brosers...
pls read "height of 15px is sufficient for the eg. here" in my comment as "height of 150px is sufficient for the eg. here"
ASKER
yep Happy!!
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#CCCCCC" text="#000000">
<td bgcolor=#003366 valign=bottom width=589>
<table border=1 cellspacing=1 cellpadding=5 width="497">
<tr> <td><a style="cursor:hand" onClick="altercontent(1)" href="#no"> Topic 1</a> <a
</table>
<div id="dcontent" style="width:589px;height:
<ilayer id="ns4dcontent" width=589px height=28px left="-1">
<layer id="ns4dcontent2" width=589px height=28px></layer></ilay
<script>
//the html contents to display
var mycontent=new Array()
mycontent[1]='Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>Topic 1<br>'
mycontent[2]='Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>Topic 2<br>'
mycontent[3]='Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>Topic 3<br>'
mycontent[4]='Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>Topic 4<br>'
mycontent[5]='Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>Topic 5<br>'
function altercontent(i){
//if IE 4+
if (document.all)
dcontent.innerHTML=myconte
//else if NS 4
else if (document.layers){
document.ns4dcontent.docum
document.write(mycontent[i
document.ns4dcontent.docum
document.close();
}
//else if NS 6 (supports new DOM)
else if (document.getElementById){
rng = document.createRange();
el = document.getElementById("d
rng.setStartBefore(el);
htmlFrag = rng.createContextualFragme
while (el.hasChildNodes())
el.removeChild(el.lastChil
el.appendChild(htmlFrag);
}
}
function beginrotation(){
if (document.all||document.la
setInterval("altercontent(
}
window.onload=beginrotatio
</script>
<p> </p></td>
</body>
</html>