jefkaone
07-04-2003, 01:39 PM
Hi everybody, :D
For my first post, i've got a problem with a script wich have to repositioned a layer in by page trought a div balise, all is working great, except with mozilla, my script is this one:
<SCRIPT>
function setLyr(obj,lyr)
{
var newX = findPosX(obj);
var newY = findPosY(obj);
if (lyr == 'testP') newY -= 50;
var x = new getObj(lyr);
x.style.top = newY + 'px';
x.style.left = newX + 'px';
}
function findPosX(obj)
{
var curleft = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (obj.x)
curleft += obj.x;
return curleft;
}
function findPosY(obj)
{
var curtop = 0;
var printstring = '';
if (obj.offsetParent)
{
while (obj.offsetParent)
{
printstring += ' element ' + obj.tagName + ' has ' + obj.offsetTop;
curtop += obj.offsetTop
obj = obj.offsetParent;
}
}
else if (obj.y)
curtop += obj.y;
window.status = printstring;
return curtop;
}
function getObj(name)
{
if (document.getElementById)
{
this.obj = document.getElementById(name);
this.style = document.getElementById(name).style;
}
else if (document.all)
{
this.obj = document.all[name];
this.style = document.all[name].style;
}
else if (document.layers)
{
if (document.layers[name])
{
this.obj = document.layers[name];
this.style = document.layers[name];
}
else
{
this.obj = document.layers.testP.layers[name];
this.style = document.layers.testP.layers[name];
}
}
}
</SCRIPT>
then, i've got in my page the div element wich is the repair of the layer <div id="positionLayer"> </div> and in body, i write : onload="setLyr(positionLayer,'LayerWhoNeedToBePositionned)", all ok with IE but not Mozilla, what i need more to make it works with mozilla?
:)
thancs for all, ++, jefkaOne.
For my first post, i've got a problem with a script wich have to repositioned a layer in by page trought a div balise, all is working great, except with mozilla, my script is this one:
<SCRIPT>
function setLyr(obj,lyr)
{
var newX = findPosX(obj);
var newY = findPosY(obj);
if (lyr == 'testP') newY -= 50;
var x = new getObj(lyr);
x.style.top = newY + 'px';
x.style.left = newX + 'px';
}
function findPosX(obj)
{
var curleft = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (obj.x)
curleft += obj.x;
return curleft;
}
function findPosY(obj)
{
var curtop = 0;
var printstring = '';
if (obj.offsetParent)
{
while (obj.offsetParent)
{
printstring += ' element ' + obj.tagName + ' has ' + obj.offsetTop;
curtop += obj.offsetTop
obj = obj.offsetParent;
}
}
else if (obj.y)
curtop += obj.y;
window.status = printstring;
return curtop;
}
function getObj(name)
{
if (document.getElementById)
{
this.obj = document.getElementById(name);
this.style = document.getElementById(name).style;
}
else if (document.all)
{
this.obj = document.all[name];
this.style = document.all[name].style;
}
else if (document.layers)
{
if (document.layers[name])
{
this.obj = document.layers[name];
this.style = document.layers[name];
}
else
{
this.obj = document.layers.testP.layers[name];
this.style = document.layers.testP.layers[name];
}
}
}
</SCRIPT>
then, i've got in my page the div element wich is the repair of the layer <div id="positionLayer"> </div> and in body, i write : onload="setLyr(positionLayer,'LayerWhoNeedToBePositionned)", all ok with IE but not Mozilla, what i need more to make it works with mozilla?
:)
thancs for all, ++, jefkaOne.