browser window coordinates

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • D. Alvarado

    browser window coordinates

    Hello,
    I have an object that is 330 pixels in width. I want to position
    it 330 pixels from the right edge of the viewable browser window.
    Unfortunately, this isn't the JS to use:

    var divObj = getDivObj(id);
    divObj.left = screen.width - 330;

    What is the proper call I should use? Thanks -
  • David Dorward

    #2
    Re: browser window coordinates

    D. Alvarado wrote:
    [color=blue]
    > Hello,
    > I have an object that is 330 pixels in width. I want to position
    > it 330 pixels from the right edge of the viewable browser window.
    > Unfortunately, this isn't the JS to use:
    >
    > var divObj = getDivObj(id);
    > divObj.left = screen.width - 330;
    >
    > What is the proper call I should use? Thanks -[/color]

    divObj.right = '330px';

    --
    David Dorward <http://dorward.me.uk/>

    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: browser window coordinates

      laredotornado@z ipmail.com (D. Alvarado) writes:
      [color=blue]
      > I have an object that is 330 pixels in width. I want to position
      > it 330 pixels from the right edge of the viewable browser window.[/color]

      Which part of it? The left or right edge? I'll assume the closest edge
      (right), as that would be the usual interpretation of distance from
      something to something else.
      [color=blue]
      > Unfortunately, this isn't the JS to use:
      >
      > var divObj = getDivObj(id);
      > divObj.left = screen.width - 330;[/color]

      It is perfectly legal JS. It doesn't do anything because DOM objects
      doesn't have a left property that means anything.

      You should not use screen.width. You should position according to the
      viewport, since that is all your page *can* access.
      [color=blue]
      > What is the proper call I should use? Thanks -[/color]

      Use CSS ("position:abso lute;right:300p x;") or set it with Javascript & DOM:
      divObj.style.po sition = "absolute";
      divObj.style.ri ght = "330px";

      /L
      --
      Lasse Reichstein Nielsen - lrn@hotpop.com
      DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      Working...