...

View Full Version : Positioning this <div>



redhead
08-03-2002, 02:50 PM
hello there.

I need a little help positioning a <div>. In its style I have its postition set to absolute and the top set to 60, but this div is the drop down bit of a drop down menu and the menu it is dropping down from is in the top right of the screen, so it is extremely hard to make it position to a certain amount from the right of the screen.

The only method i could think of is to get the width of the screen, minus how far fom the right i want it, and apply this number to the "left" attribute of the div's style.

This is the script i came up with to acheive this, but it doesnt work :confused:.




<script language="JavaScript">

var winWidth;
if (window.innerWidth) {
winWidth=window.innerWidth; // for nn
};
else if (document.all) {
winWidth=document.body.clientWidth; // for ie
};
var leftPos=winWidth-300; ////////// DISTANCE FROM LEFT////////
if (document.layers) {
document.submenu.left=leftPos; // for nn4
};
if (document.all) {
document.all.submenu.style.left=leftPos; // ie
};
if (document.getElementById) {
document.getElementById("submenu").style.left=leftPos; //nn6
};

////// Ignore this, its to make it appear and works fine ///////////
function showMenu(show) {
var visi;
if (show) {visi="visible";};
else {visi="hidden";};
if (document.layers) {
document.submenu.visibility=visi;
};
if (document.all) {
document.all.submenu.style.visibility=visi;
};
if (document.getElementById) {
document.getElementById("submenu").style.visibility=visi;
};
};

</script>



any help would be greatly appreciated :thumbsup:

Mr J
08-04-2002, 02:05 PM
I thought for IE it was pixelLeft

document.all.submenu.style.left=leftPos

document.all.submenu.style.pixelleft=leftPos



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum