document.all and css

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Stuart Wexler

    #1

    document.all and css

    Hi,

    I'm attempting to loop through the document.all collection of a page to make
    universal height, width, size changes. I am doing this on a page with a
    relative link to a css style sheet. In testing this out, I notice that it
    registers the DIV tags and such, but for some reason, it won't recognize any
    of the attributes of those DIV tags possibly because the styles are dictated
    by the .css file. Is there any way javascript can recognize style
    properties set by a separate style sheet?

    Thanks.


  • Richard Cornford

    #2
    Re: document.all and css

    "Stuart Wexler" <Studawg76@comc ast.net> wrote in message
    news:HCidnWs3EY-9MZGiXTWJhA@com cast.com...[color=blue]
    >I'm attempting to loop through the document.all collection of a
    >page to make universal height, width, size changes. I am doing
    >this on a page with a relative link to a css style sheet. In
    >testing this out, I notice that it registers the DIV tags and
    >such, but for some reason, it won't recognize any of the attributes
    >of those DIV tags possibly because the styles are dictated by the
    >.css file. Is there any way javascript can recognize style
    >properties set by a separate style sheet?[/color]

    The - style - objects of HTML elements initially only hold CSS style
    settings from inline style attributes on those elements. On IE 5.0+ HTML
    elements also have a - currentStyle - object from which the current
    settings for most CSS values for an element can be read.

    Gecko browsers have a window.getCompu tedStyle method that can provide
    some similar information for those browsers, but if you are using
    document.all to loop through the elements that will not be relevant.

    Richard.
    --

    Example JavaScript DOM listings for: Opera 7.11,
    Mozilla 1.2 and ICEbrowser 5.4
    <URL: http://www.litotes.demon.co.uk/dom_root.html >


    Comment

    • Stuart Wexler

      #3
      Re: document.all and css

      Thanks. Now I have a second question. What I'm basically doing is trying
      to ratio out font sizes, widths and heights according to the screen
      resolution property. So I have the ideal resolution, get the actual
      resolution, and get a ratio. I then want to multiply things like .left by
      the width ratio, and fontsize by the height ratio. But the problem is that
      these measurements are treated often as strings so a.left = a.left * ratio
      doesn't work. Any ideas as to how to resolve that?


      "Richard Cornford" <Richard@litote s.demon.co.uk> wrote in message
      news:beib6h$75b $1$8302bc10@new s.demon.co.uk.. .[color=blue]
      > "Stuart Wexler" <Studawg76@comc ast.net> wrote in message
      > news:HCidnWs3EY-9MZGiXTWJhA@com cast.com...[color=green]
      > >I'm attempting to loop through the document.all collection of a
      > >page to make universal height, width, size changes. I am doing
      > >this on a page with a relative link to a css style sheet. In
      > >testing this out, I notice that it registers the DIV tags and
      > >such, but for some reason, it won't recognize any of the attributes
      > >of those DIV tags possibly because the styles are dictated by the
      > >.css file. Is there any way javascript can recognize style
      > >properties set by a separate style sheet?[/color]
      >
      > The - style - objects of HTML elements initially only hold CSS style
      > settings from inline style attributes on those elements. On IE 5.0+ HTML
      > elements also have a - currentStyle - object from which the current
      > settings for most CSS values for an element can be read.
      >
      > Gecko browsers have a window.getCompu tedStyle method that can provide
      > some similar information for those browsers, but if you are using
      > document.all to loop through the elements that will not be relevant.
      >
      > Richard.
      > --
      >
      > Example JavaScript DOM listings for: Opera 7.11,
      > Mozilla 1.2 and ICEbrowser 5.4
      > <URL: http://www.litotes.demon.co.uk/dom_root.html >
      >
      >[/color]


      Comment

      • HikksNotAtHome

        #4
        Re: document.all and css

        In article <srCdnSmoL8M8fZ GiXTWJiQ@comcas t.com>, "Stuart Wexler"
        <Studawg76@comc ast.net> writes:
        [color=blue]
        >Thanks. Now I have a second question. What I'm basically doing is trying
        >to ratio out font sizes, widths and heights according to the screen
        >resolution property. So I have the ideal resolution, get the actual
        >resolution, and get a ratio. I then want to multiply things like .left by
        >the width ratio, and fontsize by the height ratio. But the problem is that
        >these measurements are treated often as strings so a.left = a.left * ratio
        >doesn't work. Any ideas as to how to resolve that?[/color]

        parseInt and parseFloat
        Or, unary + operator.

        But, in IE, the user can explicitly tell it to ignore your definitions. And
        also change the sizes without the webpage every knowing it. But my screen
        resolution is totally irrelevant to font sizes. As is my browser window size. I
        prefer reading webpages in about a 14 point font and its set that way. Nothing
        you do in Javascript will change that size either.
        --
        Randy
        All code posted is dependent upon the viewing browser
        supporting the methods called, and Javascript being enabled.

        Comment

        • Richard Cornford

          #5
          Re: document.all and css

          "Richard Cornford" <Richard@litote s.demon.co.uk> wrote in message
          news:beit56$9sv $1$8300dec7@new s.demon.co.uk.. .
          <snip>[color=blue]
          > ... . Changing the font size for the BODY could
          >scale the entire content in one operation.[/color]
          <snip>

          Thinking about it some more, if the page is only going to be sized once
          you could leave the DOM alone and just document.write a STYLE tag into
          the page as it loads that includes a specification for the BODY
          font-size (overriding a default set in the CSS style sheet) and let the
          rest of the document inherit from that.

          <script type="text/javascript">
          document.write( '<style type="text/css">\nBODY {font-size:'+
          size+
          '%;}\n<\/style>');
          </script>

          Though, as Randy pointed out, you may still be tripped up by user style
          sheet setting, but using relative CSS units throughout the rest of the
          document should (may) still leave the viewer with approximately what you
          intended, at least as far as the overall layout goes.

          Richard.


          Comment

          Working...