SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: document.all

  1. #1
    SitePoint Evangelist dscriptor's Avatar
    Join Date
    Oct 2005
    Location
    in front of my computer
    Posts
    571
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    document.all

    hi all, can someone help me how to code this line of javascript for Firefox..

    Code:
    if (document.all) fader.innerHTML = text_out; // document.all = IE only
    thanks!
    happy is the man that finds wisdom....wisdom in {PHP}.


  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  3. #3
    SitePoint Evangelist dscriptor's Avatar
    Join Date
    Oct 2005
    Location
    in front of my computer
    Posts
    571
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for quick reply..
    happy is the man that finds wisdom....wisdom in {PHP}.


  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,820
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The code to make it work cross browser is

    Code:
    fader.innerHTML = text_out;
    as all modern browsers support innerHTML.

    IE isn't the only browser to support document.all so using it to test for IE is invalid. As no one uses IE4 any more there is never any need to use document.all for anything as that is the only browser version that supports document.all that doesn't support document.getElementById and there are lots of browsers that support document.getElementById that don't support document.all.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    [QUOTE=felgall]The code to make it work cross browser is

    Code:
    fader.innerHTML = text_out;
    That depends on what fader is. If it's a string literal it won't work, but if it's an element reference, then it will.

    Quote Originally Posted by felgall
    as all modern browsers support innerHTML.
    True, but the degree of support differs, so it shouldn't be used with forms or with tables except to modify the contents of table-cells.

    Quote Originally Posted by felgall
    IE isn't the only browser to support document.all so using it to test for IE is invalid. As no one uses IE4 any more there is never any need to use document.all for anything as that is the only browser version that supports document.all that doesn't support document.getElementById and there are lots of browsers that support document.getElementById that don't support document.all.
    True, except that there is still a very small percentage of IE4 users around, unfortunately. Why they haven't upgraded to at least IE5 is beyond me.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,820
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Of the 100,000 visitors I get on my site each month, one is still using IE4. I consider 0.001% a small enough percentage to ignore. After all if we don't draw the line somewhere then you should still code your pages for that possible individual who is still running Mozaic 1.0. In any case if you design your page properly that IE4 user (and the Mozaic 1.0 user) will still see a basic version of your page just without all the fancy formatting and functionality that modern browsers understand.

    If fader.innerHTML = text_out; works on IE then it will work on recent Firefox, Opera etc versions as well. Of course you could test if (document.html) {...} to ensure that the code is ignored by antique browsers such as IE4 that don't understand it.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •