Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dymaically calculating dix box cordinates

Status
Not open for further replies.

jimberger

Programmer
Jul 5, 2001
222
GB
Hi,

I have a div box that i have set up as postion:absolute and then some pixel cordinates to postion the dix box on the screen where i want it. However, this isnt resolution compatiable, as when i change the resoltuon of my screen the div box moves. is there any piece of javascrip that can work out the resolution of the screen and the adjust the coordinates accordingly, so the dix box appears in the same place regardless of the screen resulotion. or is they any other soltution you can think of?

thanks for your help
jim
 
Something like this?
Code:
function changeBox()
{
  var w = screen.width;
  var x = 0;
  switch (w)
  {
    case 1024: x = 256; break;
    case 800: x = 200; break;
    default: x = 100; break;
  }
  var elem = document.getElementById("box");
  elem.style.left = x;
}

--Chessbot

"In that blessed region of Four Dimensions, shall we linger on the threshold of the Fifth, and not enter therein? Ah, no! [...] Then, yielding to our intellectual onset, the gates of the Sixth Dimension shall fly open; after that a Seventh, and then an Eighth -- --" Flatland, A. Square (E. A. Abbott)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top