Re: Debug Request

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Conrad Lender

    Re: Debug Request

    On 2008-10-21 18:56, Dr J R Stockton wrote:
    The page below works in Firefox & Safari, but not in IE & Opera.
    It does work in Opera (opera_9.61.245 6.gcc4.qt3_i386 ).
    Tests in IE suggest that PT is indeed set to an Object, but that the
    loop is never entered - T is false on the first entry.
    The loop is never entered because PT is an empty node list (you can
    confirm this by reading PT.length). You already know why it's empty:
    TIDY shows three like
    line 29 column 5 - Warning: <tdproprietar y attribute "name"
    which explains what is wrong.
    As you said, "name" attributes aren't allowed in <tdelements (and the
    page won't validate as HTML 4.01 Strict, either). It would appear that
    IE doesn't recognize those non-standard attributes and thus won't return
    the elements with getElementByNam e().
    Best would be something that can mark for action any element suitable
    for containing a datetime (TH, TD, SPAN, ...?) but not to search the
    body for any datetime.
    The usual solution is to assign CSS classes and use something like
    getElementsByCl assName, which will have to be retrofitted for some
    browsers. Microformats in HTML work the same way; they (mostly) use
    class names to add semantic information to generic markup:


    As a side note, I also found your code very hard to read; you will know
    what variables like PT, J, T, and functions like BB and LZ are supposed
    to represent, but I didn't, and if your script had been any longer than
    this, I wouldn't have bothered to look at it.


    - Conrad
  • dhtml

    #2
    Re: Debug Request

    Conrad Lender wrote:
    On 2008-10-21 18:56, Dr J R Stockton wrote:
    As a side note, I also found your code very hard to read; you will know
    what variables like PT, J, T, and functions like BB and LZ are supposed
    to represent, but I didn't, and if your script had been any longer than
    this, I wouldn't have bothered to look at it.
    >
    >
    Undeclared variables end up becoming global properties (or sometimes
    errors in IE). Declare them using var.

    var dateContainer = document.getEle mentById('myTbo dy'),
    dateCells = dateContainer.g etElementsByTag Name('td');

    Garrett
    - Conrad

    --
    comp.lang.javas cript FAQ <URL: http://jibbering.com/faq/ >

    Comment

    • Dr J R Stockton

      #3
      Re: Debug Request

      On Oct 22, 1:13 am, Conrad Lender <crlen...@yahoo .comwrote:
      On 2008-10-21 18:56, Dr J R Stockton wrote:
      >
      The page below works in Firefox & Safari, but not in IE & Opera.
      >
      It does work in Opera (opera_9.61.245 6.gcc4.qt3_i386 ).
      That was 9.27. I keep 9.27 on this machine until I have *memorised*
      the replacement fot Ctrl-Alt-V.

      The usual solution is to assign CSS classes and use something like
      getElementsByCl assName, which will have to be retrofitted for some
      browsers. Microformats in HTML work the same way; they (mostly) use
      class names to add semantic information to generic markup:http://en.wikipedia.org/wiki/Microformat
      As you can see from my second post in this thread, I discovered that.
      If "Microforma t" becomes common in CLJ or FAQ, it's a glossary
      candidate.


      There remains one strangeness. Whilst the code is intended to be
      called by body onLoad, therefore only once, the demo version now at
      the foot of js-tests9.htm has a button. In IE, FF, Op, Sf, Ch, the
      button works when first pressed. In all bar Opera, it works (though
      not usefully) on a second press. In Opera (9.27, 9.61), the button
      sort of seems to be stuck down, although other buttons on the page
      still work. So it does not matter, but there's a bug or an amazing
      feature somewhere.

      As a side note, I also found your code very hard to read; you will know
      what variables like PT, J, T, and functions like BB and LZ are supposed
      to represent, but I didn't, and if your script had been any longer than
      this, I wouldn't have bothered to look at it.
      I like short variables when their lexical scope is short, or, like LZ,
      I use them a lot; and I like them in new code. It eliminates one
      class of bug : e.g. all wrong ways of spelling J are obvious at a
      glance. They have neen lengthened in js-date9.htm#LCT.

      IMHO, LZ should be in the FAQ; either in a Date context, or as an
      example of how lexically-repetitive actions should be treated.


      I don't see how dhtml's remark on undeclared variables might apply
      here.

      --
      (c) John Stockton, near London, UK. Posting with Google.
      Mail: J.R.""""""""@ph ysics.org or (better) via Home Page at
      Web: <URL:http://www.merlyn.demo n.co.uk/>
      FAQish topics, acronyms, links, etc.; Date, Delphi, JavaScript, ....|

      Comment

      • Dr J R Stockton

        #4
        Re: Debug Request

        Dr J R Stockton wrote:

        [js-date9.htm#LCT]
        There remains one strangeness. Whilst the code is intended to be
        called by body onLoad, therefore only once, the demo version now at
        the foot of js-tests9.htm has a button. In IE, FF, Op, Sf, Ch, the
        button works when first pressed. In all bar Opera, it works (though
        not usefully) on a second press. In Opera (9.27, 9.61), the button
        sort of seems to be stuck down, although other buttons on the page
        still work. So it does not matter, but there's a bug or an amazing
        feature somewhere.
        Explained. Opera ignores alphabetic zone offset indications, apart
        from GMT & UTC, AFAICS. Therefote it ignores LCT, which stands
        for Local Civil Time but is not expected to be recognised by a
        browser.

        --
        (c) John Stockton, near London, UK. Posting with Google.
        Mail: J.R.""""""""@ph ysics.org or (better) via Home Page at
        Web: <URL:http://www.merlyn.demo n.co.uk/>
        FAQish topics, acronyms, links, etc.; Date, Delphi, JavaScript, ....|

        Comment

        Working...