Forum Moderators: open

Message Too Old, No Replies

How do I get the id of a Div?

         

JAB Creations

5:10 pm on Nov 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm trying to get my right DIV (id="rightdiv") to have the same height as the content div (id="myDiv2"). The idea is to have the side DIV be 100% of whatever the pixel height is of the grey DIV area. I will be adding a rollover effect so the BG 1px high work around won't work for me.

What I am guessing I need to do is get

File 1 of 2
Frame (Insert my username as the domain where you see $$$$$$. Frame is required for the page within to be rendered corretly (for the time being).

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>Home (No Music)</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--
if (top.location!= location) top.location.href = location.href;
// -->
</script>
</head>

<frameset rows="5,1*,32" border="0">
<frame src="http://www.$$$$$$.com/home/home-border-top.php" frameborder="0" name="border" scrolling="no">
<frame src="right_div.html" frameborder="0" name="content" noresize="noresize" scrolling="no">

<frameset cols="1*,431" border="0">
<frame src="http://www.$$$$$$.com/home/home-border-bottom-1.php" frameborder="0" name="copyright" noresize="noresize" scrolling="no">
<frame src="http://www.$$$$$$.com/mplayer/jab-creations-home-choose.htm" frameborder="0" name="mplayer" noresize="noresize" scrolling="no">
</frameset>
</frameset>
</html>

File 2 of 2
Framed file named "right_div.html"

<html>
<head>
<style>
body {
background: #000000;
color: #a7a68f;
}
div.body {
background: #000000;
border: 1px solid #FFFFFF;
bottom: 10px;
left: 10px;
margin: 0px 0px 0px 0px;
overflow: auto;
padding: 12px 0px 0px 0px;
position: absolute;
scrollbar-3dlight-color: #000000;
scrollbar-arrow-color: #00FF00;
scrollbar-base-color: #000000;
scrollbar-darkshadow-color: #000000;
scrollbar-face-color: #000000;
scrollbar-highlight-color: #EBEF92;
scrollbar-shadow-color: #EBEF92;
scrollbar-track-color: #000000;
right: 10px;
top: 10px;
z-index: 1;
}
div.left {
border: 1px solid #a7a68f;
border-width: 1px 1px 1px 1px;
float: right;
right: 160px;
margin: 0px 4px 0px 0px;
}
div.inset {
background: #222222;
border: solid #a7a68f;
border-width: 0px 0px 0px 1px;
float: right;
margin: 0px;
padding: 0px 4px 4px 4px;
width: 150px;
}
div.inset-hover {
background: #4e4e4e;
border: solid #a7a68f;
border-width: 0px 0px 0px 1px;
float: right;
margin: 0px;
padding: 0px 4px 4px 4px;
width: 150px;
}
p {
margin:0;
}
</style>
</head>
<body onResize="window.location=window.location;">

<script type="text/javascript">
<!--
var width; var height; width = document.body.clientWidth-20; height = document.body.clientHeight-20;
function setDivSize(){ document.getElementById('myDiv').style.width = width; document.getElementById('myDiv').style.height = height; }
document.writeln('<div id="myDiv" class="body">'); resizeDiv();
//-->
</script>

<script type="text/javascript">
<!--
var contentwidth; contentwidth = document.body.clientWidth-160;
function setTableSize(){document.getElementById('myDiv2').style.width = contentwidth; }
document.writeln('<div id="myDiv2" class="left">'); resizeTable();
//-->
</script>
<script type="text/javascript">
<!--
var rightheight; rightheight = document.body.mydiv2;
function setTableSize(){document.getElementById('rightdiv').style.height = rightheight; }
document.writeln('<div id="rightdiv" class="inset">'); resizeTable();
//-->
</script>

Right Div Stuff here!

<script type="text/javascript">
<!--
document.writeln('</div>'); setDivSize();
//-->
</script>
1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />
1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />
1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />1<br />
<script type="text/javascript">
<!--
document.writeln('</div>'); setTableSize();
//-->
</script>

<script type="text/javascript">
<!--
document.writeln('</div>'); setDivSize();
//-->
</script>
</body>
</html>

adni18

12:59 pm on Nov 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To get all the divs on a page, try this:


stringbeans=document.getElementsByTagName("div");
for (var w=0;w<stringbeans.length;w++)
{
if(stringbeans[w].id=="whatever"){alert("Ding ding! This div has an id of whatever!")}
}

By the way, how do you get that greyed-in area? I can never get that!

JAB Creations

6:05 pm on Nov 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'll have to try that when I reattach my other drives... I killed off my program files dir and the dam thing wont let me install world of warcraft on my normal sys...

Anyway :hover only works in CSS with hyperlinks for IE. Although all other browsers support :hover as far as I know you'll have to use the onmouseover / onmouseout script.

It would be nice if IE supported :hover because it would allow me to further reduce my CSS and take out the javascript but it's like asking for water in a desert >__>.

View the code on my site, link in my profile.

Oh yeah I'll try the code out when I hook my other drives up.

JAB Creations

12:29 am on Nov 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your script did not work?

I will be working on original issue and will post my results when I feel I can't go any further ...