FAQ Suggestion

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

    FAQ Suggestion

    Tried mailing the FAQ maintainer but the mail bounced.

    The FAQ entry of topic:


    DocDom = (document.getEl ementById?true: false);
    DocAll = (document.all?t rue:false);
    DocStr=''
    if (DocAll) DocStr="return document.all[id]"
    if (DocDom) DocStr="return document.getEle mentById(id)"
    GetRef=new Function("id", DocStr)
    if (DocStr=='') { DynWrite=new Function("retur n false") } else {
    DynWrite=new Function("id", "S", "GetRef(id).inn erHTML=S; return
    true")
    }

    Is a very poor quality example. Anyone reading that code who knows
    what they are doing would probably consider the advice in the document
    worthless.

    It should be revised to not use the function constructor, for one. It
    should definitely not declare variables without the var keyword. The
    DocDom variable is also questionable. Does "DocDom" being true imply
    something other than "document.getEl ementById" exists?

    The explanation before the example is sufficient.

    It would be a good idea to add something about script tag insertion.
    This comes up fairly often.

    =============== =============== ==========
    SCRIPT tags inserted with innerHTML will not be evaluated in most
    circumstances. Appending a
    script tag will cause the script to be executed in most browsers.
    --------------------------------------------------------
    [example]
    --------------------------------------------------------

    =============== =============== ==========
  • RobG

    #2
    Re: FAQ Suggestion

    On Aug 8, 10:41 am, dhtml <dhtmlkitc...@g mail.comwrote:
    Tried mailing the FAQ maintainer but the mail bounced.
    The best method has been to follow the advice in FAQ 5:

    <URL: http://www.jibbering.com/faq/#FAQ5 >


    Constructive criticism is welcome but insufficient to get entries
    changed. The most successful process has been to post the suggested
    revised entry here with reasons for the update.

    The FAQ maintainer should then update the FAQ (or not) depending on
    the response the post. If the current maintainer continues to be
    elusive, perhaps it's time to look for a new volunteer.


    --
    Rob

    Comment

    • Jim Ley

      #3
      Re: FAQ Suggestion

      On Thu, 7 Aug 2008 17:41:13 -0700 (PDT), dhtml
      <dhtmlkitchen@g mail.comwrote:
      >Tried mailing the FAQ maintainer but the mail bounced.
      the jim@jibbering.c om one? what message? jim.ley@gmail.c om also
      works and has a different set of filtering/spam protection on it.

      I do agree on the updates - do we have a new maintainer that I should
      give access too?

      Cheers,

      Jim.

      Comment

      • dhtml

        #4
        Re: FAQ Suggestion

        On Aug 8, 3:41 am, j...@jibbering. com (Jim Ley) wrote:
        On Thu, 7 Aug 2008 17:41:13 -0700 (PDT), dhtml
        >
        <dhtmlkitc...@g mail.comwrote:
        Tried mailing the FAQ maintainer but the mail bounced.
        >
        the j...@jibbering. com  one?  what message?  jim....@gmail.c om also
        works and has a different set of filtering/spam protection  on it.
        >
        I used the gmail one the second time. The mail I sent to Randy Webb
        (cljfaq@comcast .net) bounced.

        The one I sent to your gmail account did not.
        I do agree on the updates - do we have a new maintainer that I should
        give access too?
        I don't think we do. Do we?
        >
        Cheers,
        >
        Jim.

        Comment

        • Dr J R Stockton

          #5
          Re: FAQ Suggestion

          In comp.lang.javas cript message <8c1dcb4b-f395-4ff4-aa26-5913024bdd3a@y1
          9g2000prn.googl egroups.com>, Thu, 7 Aug 2008 17:41:13, dhtml
          <dhtmlkitchen@g mail.composted:
          >Tried mailing the FAQ maintainer but the mail bounced.
          That shows why FAQ 5.2 needs a change.
          >The FAQ entry of topic:
          >http://www.jibbering.com/faq/#FAQ4_15
          >
          >DocDom = (document.getEl ementById?true: false);
          >DocAll = (document.all?t rue:false);
          >DocStr=''
          >if (DocAll) DocStr="return document.all[id]"
          >if (DocDom) DocStr="return document.getEle mentById(id)"
          >GetRef=new Function("id", DocStr)
          >if (DocStr=='') { DynWrite=new Function("retur n false") } else {
          DynWrite=new Function("id", "S", "GetRef(id).inn erHTML=S; return
          >true")
          >}
          >
          >Is a very poor quality example. Anyone reading that code who knows
          >what they are doing would probably consider the advice in the document
          >worthless.
          Clearly postfix ?true:false should be replaced by prefix !! .
          >It should be revised to not use the function constructor, for one. It
          >should definitely not declare variables without the var keyword.
          If the whole is encased in a function (as I (an original *user*) did),
          the lack of var makes then usefully global.
          The
          >DocDom variable is also questionable. Does "DocDom" being true imply
          >something other than "document.getEl ementById" exists?
          >
          >The explanation before the example is sufficient.
          One wonders whether "insufficie nt" was intended.


          The common way now is AIUI to use either DOM methods or less modern
          document.getEle mentById(ID).in nerHTML = S

          In either case, the code should, for overall brevity and structure, be
          encapsulated in, say,
          function Wryt(ID, S) { /* ... */ }
          and it would be good to see that in the FAQ.

          If it is necessary to support browsers without document.getEle mentById,
          one can include something like
          if (document.all && !document.getEl ementById) {
          document.getEle mentById =
          function(id) { return document.all[id] } } ,
          the documentation of which needs a note indicating that and how it is
          not fully equivalent.

          --
          (c) John Stockton, nr London, UK. ?@merlyn.demon. co.uk Turnpike v6.05 MIME.
          Web <URL:http://www.merlyn.demo n.co.uk/- FAQish topics, acronyms, & links.
          Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
          Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036)

          Comment

          • dhtml

            #6
            Re: FAQ Suggestion

            On Aug 8, 12:39 pm, Dr J R Stockton <j...@merlyn.de mon.co.ukwrote:
            In comp.lang.javas cript message <8c1dcb4b-f395-4ff4-aa26-5913024bdd3a@y1
            9g2000prn.googl egroups.com>, Thu, 7 Aug 2008 17:41:13, dhtml
            <dhtmlkitc...@g mail.composted:
            >
            Tried mailing the FAQ maintainer but the mail bounced.
            >
            That shows why FAQ 5.2 needs a change.
            >
            Sure.
            Clearly postfix  ?true:false  should be replaced by prefix !! .
            >
            I don't think the DocDom variable needs to be declared at all. I don't
            think this needs to be function, either. el.innerHTML = s is
            sufficient.

            Declaring global variables inside a function by omitting var makes the
            globals hard to notice. It looks like a mistake from the careful eye,
            and would go unnoticed by a quick lookover. It can also cause an error
            if there is an element with the same name

            The common problem is the variable i used in loops;

            Douglas Crockford actually advises not using var:


            But provides no explanation other than: "There's a bug in IE."
            var pity = this.pity || {};alert(pity)

            No explanation of what happens in IE or what should happen.

            The problem with omitting var in IE is that it can create conflict
            with objects that get added to the global object as apparently
            readonly.

            <div id=Menu></div>
            <script>
            Menu = {};
            </script>

            Error in MSIE.

            However:
            <div id=Menu></div>
            <script>
            var Menu = {};
            </script>

            Will not cause an error.

            IE8 could fix this for standards mode, and only fall back to the buggy
            behavior for quirks mode, but they probably won't. They could not
            reproduce the bug I filed on this.
            >
            The explanation before the example is sufficient.
            >
            One wonders whether "insufficie nt" was intended.
            No, I meant 'sufficient' there's just a simple explanation of
            something like:
            el.innerHTML = "hello <em>world</em>"; or something like that. It
            seemed sufficient. There's no need to write a helper function for
            innerHTML. It woul only make the code slower and more complex.
            >
            The common way now is AIUI to use either DOM methods or less modern
                    document.getEle mentById(ID).in nerHTML = S
            >
            Right.
            >
            --

            Comment

            • Mike Duffy

              #7
              Re: FAQ Suggestion

              dhtml <dhtmlkitchen@g mail.comwrote in news:1616178e-b10c-491f-8e5a-
              10a990f31360@w1 g2000prk.google groups.com:
              >
              Declaring global variables inside a function by omitting var
              Good Lord! This explains a lot of my problems. I always thought that they
              were global only if declared explicitely as a var *outside* of all
              functions.

              Thanks for the tip! I thinks it's time for a little code review. In any
              case I usually declare everything in functions, mostly out of habit from
              using more restrictive languages, so it should not turn up a lot of
              changes.

              One little question though. When does the global definition dissapear? The
              reason I ask is because am restricted to using static pages, and where cgi
              or asp should really be used I instead have a habit of building a new page
              into a string and then using document.write if I need to change the <head>
              section or simply changing the innerHtml on an element which comprises the
              entire <bodysection. I have had "issues" in the past regarding globals in
              the resulting javascript.

              Do variables declared within event handlers (i.e. <img onLoad="blah blah"
              get treated the same way? (i.e. do they become global?)

              Comment

              • dhtml

                #8
                Re: FAQ Suggestion

                Mike Duffy wrote:
                dhtml <dhtmlkitchen@g mail.comwrote in news:1616178e-b10c-491f-8e5a-
                10a990f31360@w1 g2000prk.google groups.com:
                >
                >
                One little question though. When does the global definition dissapear? The
                reason I ask is because am restricted to using static pages, and where cgi
                or asp should really be used I instead have a habit of building a new page
                into a string and then using document.write if I need to change the <head>
                section or simply changing the innerHtml on an element which comprises the
                entire <bodysection.
                That's not a good way to write maintainable code.
                I have had "issues" in the past regarding globals in
                the resulting javascript.
                >
                Do variables declared within event handlers (i.e. <img onLoad="blah blah"
                get treated the same way? (i.e. do they become global?)
                Yes, Identifiers are resolved the same way. If no Identifier is found,
                it is a global assignment.

                Comment

                • Thomas 'PointedEars' Lahn

                  #9
                  Re: FAQ Suggestion

                  Mike Duffy wrote:
                  dhtml <dhtmlkitchen@g mail.comwrote [...]:
                  >Declaring global variables inside a function by omitting var
                  >
                  Good Lord! This explains a lot of my problems. I always thought that they
                  were global only if declared explicitely as a var *outside* of all
                  functions.
                  In a way, you are correct, and "dhtml" is not (which has been explained
                  before here). Because what has not been declared a variable will never
                  magically become one. Instead, use of an undeclared identifier left-hand
                  side in an assignment leads to its resolution along the scope chain; if no
                  object in the scope chain has a property with that name, the Global Object
                  will be augmented with one. The most important difference to a global
                  variable is that this new property can be deleted.


                  PointedEars
                  --
                  Anyone who slaps a 'this page is best viewed with Browser X' label on
                  a Web page appears to be yearning for the bad old days, before the Web,
                  when you had very little chance of reading a document written on another
                  computer, another word processor, or another network. -- Tim Berners-Lee

                  Comment

                  • Mike Duffy

                    #10
                    Re: FAQ Suggestion

                    dhtml <tomomi@comcast .netwrote in
                    news:bpqdnd0bB4 9HiQDVnZ2dnUVZ_ ozinZ2d@comcast .com:
                    Mike Duffy wrote:
                    >dhtml <dhtmlkitchen@g mail.comwrote in news:1616178e-b10c-491f-8e5a-
                    >10a990f31360@w1 g2000prk.google groups.com:
                    >>
                    >
                    That's not a good way to write maintainable code.
                    You're telling me! One of the hardest things is working with strings,
                    because you are building the html into strings which contains the javacript
                    within quotes, which itself needs to have quoted material. It gets
                    especially tricky when you want to define on-the-fly html tags with in-line
                    event handlers.

                    Of course, if I had a business-related site I would pay extra and use ASP /
                    AJAX / CGI.

                    If anyone is interested, you need to do a "document.close ", then
                    "document.o pen" before the "document.write " if you want a web page with a
                    new <headsection. You can see an example of a dynamically-generated page
                    on a static server if you go to my javascript phone poem generator. Go to
                    my poetry page at:



                    and take the exam at the bottom of the page.

                    Comment

                    • dhtml

                      #11
                      Re: FAQ Suggestion

                      Thomas 'PointedEars' Lahn wrote:
                      Mike Duffy wrote:
                      >dhtml <dhtmlkitchen@g mail.comwrote [...]:
                      >>Declaring global variables inside a function by omitting var
                      >Good Lord! This explains a lot of my problems. I always thought that they
                      >were global only if declared explicitely as a var *outside* of all
                      >functions.
                      >
                      In a way, you are correct, and "dhtml" is not (which has been explained
                      before here). Because what has not been declared a variable will never
                      magically become one. Instead, use of an undeclared identifier left-hand
                      side in an assignment leads to its resolution along the scope chain; if no
                      object in the scope chain has a property with that name, the Global Object
                      will be augmented with one. The most important difference to a global
                      variable is that this new property can be deleted.
                      >
                      Thomas is technically correct.

                      It follows from:
                      11.13.1 Simple Assignment (= )
                      and
                      8.7.2 PutValue(V, W)

                      Where PutValue step 6, a property is assigned to the global object.

                      However, MSIE has different behavior, depending on the identifier.

                      1.
                      <div id='Menu'></div>
                      <script>
                      this.Menu = {} ;
                      </script>

                      No Error

                      2.
                      <div id='Menu'></div>
                      <script>
                      Menu = {} ;
                      </script>

                      Error in IE8 in standards mode.


                      Status Closed (Not Reproducible)

                      Assigning a property to the global object works without error in IE
                      (example 1) but in contrast example 2 causes an error.

                      Why does Douglas Crockford advise not using var for globals? What's the
                      IE bug he mentions in passing?



                      | JavaScript provides three ways of declaring a global variable,
                      | and they all have problems.
                      ....

                      | IE gets the second form wrong, so that responsibly
                      | adaptive programs fail when using constructs like
                      |
                      | var pity = this.pity || {};

                      What's this bug in IE?

                      All globals should be declared explicitly (using var). It's explicit and
                      it avoids the bug I mentioned (above). Global functions can be declared
                      with a FunctionDeclara tion.

                      Garrett
                      >
                      PointedEars

                      Comment

                      • Thomas 'PointedEars' Lahn

                        #12
                        Re: FAQ Suggestion

                        Jim Ley wrote:
                        I do agree on the updates - do we have a new maintainer that I should
                        give access too?
                        We might have one.

                        As I have said in [1] before, I have been considering to contribute in that
                        way, too, for quite a while. That started when the current maintainer
                        refused to think about any changes based upon their own initiative and even
                        argued against posting conventions recommended in the FAQ[2], which is not
                        what I think a responsible FAQ maintainer should do.[3]

                        At that time, I actually considered supporting him in the task rather than
                        taking over, but I had much too little free time on my hands even for that.

                        This has changed now that I am dealing with fewer but larger projects in my
                        job, and particularly at this time of year where most customers are on
                        holiday.

                        Therefore, I am hereby volunteering for the job.

                        As I have said repeatedly, I second that the FAQ desperately needs
                        improvement in several places (e.g. [4]), and I am going to do my
                        best to make it so.

                        [1] <news:47EF91C8. 80005@PointedEa rs.de>
                        [2] <news:474CAB04. 6080309@Pointed Ears.de>
                        [3] <news:4702A484. 1060802@Pointed Ears.de>
                        [4] <news:46DCA352. 2030609@Pointed Ears.de>
                        <news:470806F8. 2090308@Pointed Ears.de>

                        Some things about me:

                        - IIRC, I have been dealing with JavaScript, JScript, and other ECMAScript
                        implementations for about 12 years now, of those about 9 professionally.
                        I have been doing Web development for about 14 years now (while my home
                        page certainly does not show it [yet], but I hope my solutions elsewhere
                        and my record here do). That includes Apache and IIS Web server
                        administration. (I am only mentioning this because I consider it
                        important for the maintainer of a technical FAQ to know their stuff well.)

                        - I have written several multi-purpose script libraries and published them
                        under the GNU General Public License. (Follow "Scripting" on my home page
                        or ask Google).

                        - I have been maintaining the ECMAScript Support Matrix for 3 years, which
                        is hopefully going to be a comprehensive comparison of the features of
                        existing ECMAScript implementations one day.

                        - I have never written any "Javascript " book ;-)

                        - I have been regularly contributing to technical Usenet newsgroups,
                        particularly de.comp.lang.ja vascript and this newsgroup, for about 6
                        years now (with a one-year pause in-between). I have made some minor
                        contributions to the de.comp.lang.ja vascript FAQ, but I have never
                        maintained a FAQ before.

                        - I consider myself a hacker[1], which is the main reason why I think we
                        need a good FAQ: (free) time is too precious to be wasted on solving old
                        problems; existing solutions should be able to be found quickly and
                        referred to more easily. They should be understandable by anyone willing
                        to learn without much asking further questions about them here.

                        [1] <http://www.catb.org/~esr/faqs/hacker-howto.html>

                        - I am born German, living and working in Switzerland since about 2
                        years. While my English has been rated quite good recently, when
                        implementing changes I might still rely on the better judgment of those
                        who speak it as native language.

                        - I have a full-time job and I am continuing my university-level studies in
                        computer science with distance learning, which means that I would do this
                        in what is left of my free time. I am going to reserve a time slot for
                        regular FAQ reviews on the weekends. I might be able to do little changes
                        in-between.

                        - I would maintain the FAQ under one condition: You would have to trust me
                        in the regard that after I have carefully considered all arguments
                        provided here, I would make the final decision what is or is not going to
                        be in the FAQ at a certain point (unless Jim objected to that; it is his
                        Web site, after all).

                        If you can accept that, just drop me a note, and I will be glad to take over
                        and to set things in motion again.


                        Regards,

                        PointedEars
                        --
                        var bugRiddenCrashP ronePieceOfJunk = (
                        navigator.userA gent.indexOf('M SIE 5') != -1
                        && navigator.userA gent.indexOf('M ac') != -1
                        ) // Plone, register_functi on.js:16

                        Comment

                        • Laurent vilday

                          #13
                          Re: FAQ Suggestion

                          Thomas 'PointedEars' Lahn a écrit :
                          Jim Ley wrote:
                          >I do agree on the updates - do we have a new maintainer that I should
                          >give access too?
                          >
                          We might have one.
                          Well, not you I hope for the sanity of FAQ readibiliy.
                          At that time, I actually considered supporting him in the task rather than
                          taking over, but I had much too little free time on my hands even for that.
                          If only it was true, at least clj would get rid of you, but it is not
                          true, not at all. You have *way* *too* much free time on your hands,
                          just take a look at the posting time of your boring posts here at clj
                          (not even looking at the de.* hierarchy which I suppose is full of your
                          silly posts : "This is not javascript, it is JavaScript." Pfff,
                          ridiculous little one)
                          - I would maintain the FAQ under one condition: You would have to trust me
                          in the regard that after I have carefully considered all arguments
                          provided here, I would make the final decision what is or is not going to
                          be in the FAQ at a certain point (unless Jim objected to that; it is his
                          Web site, after all).
                          Good lord, that is the *main* reason to *NOT* choose you, and there are
                          a lot more reasons to not to. For a start, You can't be trusted.
                          Trustable people doesn't consider themselves as superior from the
                          others. Which is obviously not the case with you.

                          --
                          laurent

                          Comment

                          • dhtml

                            #14
                            Re: FAQ Suggestion

                            On Aug 10, 6:01 am, Laurent vilday <mok...@mokhet. comwrote:
                            Thomas 'PointedEars' Lahn a écrit :
                            >
                            Jim Ley wrote:
                            >
                            Good lord, that is the *main* reason to *NOT* choose you, and there are
                            a lot more reasons to not to. For a start, You can't be trusted.
                            Trustable people doesn't consider themselves as superior from the
                            others. Which is obviously not the case with you.
                            It's not much of a position of authority, though it could potentially
                            be used to scare off/insult new users. I think if that were to happen,
                            it would be good reason to change the FAQ maintainer immediately. The
                            FAQ maintainer should be a model citizen on the group, not pointlessly
                            argumentative.

                            Whoever takes over ought to take the comments there under
                            consideration.


                            I'm half tempted to volunteer, but I'm starting another project right
                            now. Its related to something Microsoft says is "designed to work in
                            standard mode out of this box." Something that "will take the web
                            experience beyond the page whether you are a web developer writing to
                            standards or a user.."

                            How about Lasse? or Bart Van der Donck? Whoever it is, should have
                            good knowledge of Ecma-262 r3 and Browsers and, as I said before, a
                            model citizen for the newsgroup (sans insults, arguing over minutiae
                            to miss the point, et c).

                            Garrett
                            >
                            --
                            laurent

                            Comment

                            • Dr J R Stockton

                              #15
                              Re: FAQ Suggestion

                              In comp.lang.javas cript message <489EC79B.60305 09@PointedEars. de>, Sun,
                              10 Aug 2008 12:48:59, Thomas 'PointedEars' Lahn <PointedEars@we b.de>
                              posted:
                              >
                              >Therefore, I am hereby volunteering for the job.
                              One such as yourself is entirely unfitted to the job. It requires a
                              reasonably normal human being.

                              --
                              (c) John Stockton, nr London UK. replyYYWW merlyn demon co uk Turnpike 6.05.
                              Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html-Timo Salmi: Usenet Q&A.
                              Web <URL:http://www.merlyn.demo n.co.uk/news-use.htm: about usage of News.
                              No Encoding. Quotes precede replies. Snip well. Write clearly. Mail no News.

                              Comment

                              Working...