Hello all,
I'm trying to center a <DIV> element in a user control that I created as a header for a website. I was able to do this by using the following script code that I found on MSDN...
<SCRIPT>
function center(oNode){
oNode.style.setExpression("left","getCenter(this)");
}
function getCenter(oNode){
var oParent=oNode.parentElement;
return (oParent.offsetWidth/2 - oNode.offsetWidth/2);
}
</SCRIPT>
and then calling this function in the <DIV> element using onclick="center(this)". This works!
The issue I have is that I want to have this called automatically on page load rather then through user intervention. The <DIV> tag seems to lack the onload event that I was planning to use.
Any ideas? Thanx in advance!
inzo
I'm trying to center a <DIV> element in a user control that I created as a header for a website. I was able to do this by using the following script code that I found on MSDN...
<SCRIPT>
function center(oNode){
oNode.style.setExpression("left","getCenter(this)");
}
function getCenter(oNode){
var oParent=oNode.parentElement;
return (oParent.offsetWidth/2 - oNode.offsetWidth/2);
}
</SCRIPT>
and then calling this function in the <DIV> element using onclick="center(this)". This works!
The issue I have is that I want to have this called automatically on page load rather then through user intervention. The <DIV> tag seems to lack the onload event that I was planning to use.
Any ideas? Thanx in advance!
inzo