
September 11th, 2012, 05:05 PM
|
|
Registered User
|
|
Join Date: Jul 2006
Posts: 22
Time spent in forums: 2 h 57 m 25 sec
Reputation Power: 0
|
|
|
X/y position of nested div - IE?
I have a tabbed environment.
Parent div with a div for each tab.
Inside one tab are a set of options - each a div.
On selecting one of the options a greyed-out div is laid over the other divs rendering them inoperable so only one option can be fed to the form.
This code works well - but IE doesn't like it (the nested divs?).
It gets the size right but not x or y pos.
I wonder about using jquery - ?
I generally wonder
Any suggestions would be most welcome.
Code:
function disableDivs() {
d = document.getElementsByTagName("BODY")[0];
for(x=0;x<arguments.length;x++) { if (document.getElementById(arguments[x])) {
xPos = document.getElementById(arguments[x]).offsetLeft;
yPos = document.getElementById(arguments[x]).offsetTop;
oWidth = document.getElementById(arguments[x]).offsetWidth;
oHeight = document.getElementById(arguments[x]).offsetHeight;
cDivs[cDivs.length] = document.createElement("DIV");
cDivs[cDivs.length-1].style.width = oWidth+"px";
cDivs[cDivs.length-1].style.height = oHeight+"px";
cDivs[cDivs.length-1].style.position = "absolute";
cDivs[cDivs.length-1].style.left = xPos+"px";
cDivs[cDivs.length-1].style.top = yPos+"px";
cDivs[cDivs.length-1].style.backgroundColor = "#999999";
cDivs[cDivs.length-1].style.opacity = .5;
cDivs[cDivs.length-1].style.filter = "alpha(opacity=50)";
d.appendChild(cDivs[cDivs.length-1]); }}}
function hideCDivs() { for (hippopotamus=0;hippopotamus<cDivs.length;hippopotamus++) {
document.getElementsByTagName("BODY")[0].removeChild(cDivs[hippopotamus]); }
cDivs = []; }
|