Hmm. Anyone go chapter and verse on this one?

Discussion in 'Javascript' started by The Natural Philosopher, Oct 17, 2007.

  1. Consider:

    <script type="text/javascript" language="JavaScript">
    function foo()
    {
    var dung;
    dung=document.getElementsByName('foo')[0].value;
    Alert(dung);
    }
    </script>
    <INPUT type="hidden" name="foo" value="shite">


    <b onclick="foo()">Click here for an opinion on Javascript</b>

    Works in everything except IE. IE6/7 seems to regard
    document.getElementsByName('foo') as including the function itself and
    gives an 'error in page' response. Or perhaps it finds it first, and
    that's why the error occurs.

    I am sure there s some reason why it works in other browsers but not in
    IE, but what is it?
    The Natural Philosopher, Oct 17, 2007
    #1
    1. Advertising

  2. Randy Webb wrote:
    > The Natural Philosopher said the following on 10/17/2007 3:02 PM:
    >>
    >> Consider:
    >>
    >> <script type="text/javascript" language="JavaScript">
    >> function foo()
    >> {
    >> var dung;
    >> dung=document.getElementsByName('foo')[0].value;
    >> Alert(dung);
    >> }
    >> </script>
    >> <INPUT type="hidden" name="foo" value="shite">
    >>
    >>
    >> <b onclick="foo()">Click here for an opinion on Javascript</b>
    >>
    >> Works in everything except IE.

    >
    > Firefox2.0: Alert is not defined.
    > Opera9: Statement on line 6: Reference to undefined variable: Alert
    >
    > So, I don't believe your "Works in everything except IE".
    >
    >> IE6/7 seems to regard document.getElementsByName('foo') as including
    >> the function itself and gives an 'error in page' response. Or perhaps
    >> it finds it first, and that's why the error occurs.

    >
    > No, it gives the error message (IE7) of "Object expected" because it is
    > trying to call a function named Alert with a parameter of dung and since
    > Alert doesn't exist it throws the error.
    >
    > Try the Error Console in Firefox or Opera and reading the error messages
    > there.
    >
    >> I am sure there s some reason why it works in other browsers but not
    >> in IE, but what is it?

    >
    > I don't believe it works in other browsers because testing shows me that
    > it doesn't work in other browsers. Change it to alert instead of Alert
    > and try again.


    That was the one bit I didn't test.;-)

    you have focussed on an obvious bug and completely failed to address the
    actual question.

    Does that make you look smart? or stoopid?
    The Natural Philosopher, Oct 18, 2007
    #2
    1. Advertising

  3. Randy Webb wrote:
    > The Natural Philosopher said the following on 10/17/2007 8:33 PM:
    >
    > <snip>
    >
    >> That was the one bit I didn't test.;-)
    >>
    >> you have focussed on an obvious bug and completely failed to address
    >> the actual question.

    >
    > The "bug" being your total inability to write a script?
    >


    I wrote it and it worked, or didnt work in IE.

    What I posted was a demonstrative snippet that I got wrong and didn't test.


    The point being that if you have a function and a variable with the same
    name, and do a getElementsbyName on the form, in firefox and opera the
    input is the zero'th element of the returned array, in IE the browser
    throws an error if you access the zeroth element.


    >> Does that make you look smart? or stoopid?

    >
    > Go troll somewhere else please.
    >


    Stoopid it is.
    I guess you simply didn't know the answer.
    The Natural Philosopher, Oct 18, 2007
    #3
  4. Randy Webb wrote:
    > The Natural Philosopher said the following on 10/18/2007 5:40 AM:
    >> Randy Webb wrote:
    >>> The Natural Philosopher said the following on 10/17/2007 8:33 PM:
    >>>
    >>> <snip>
    >>>
    >>>> That was the one bit I didn't test.;-)
    >>>>
    >>>> you have focussed on an obvious bug and completely failed to address
    >>>> the actual question.
    >>>
    >>> The "bug" being your total inability to write a script?
    >>>

    >>
    >> I wrote it and it worked, or didnt work in IE.
    >>
    >> What I posted was a demonstrative snippet that I got wrong and didn't
    >> test.
    >> The point being that if you have a function and a variable with the
    >> same name, and do a getElementsbyName on the form, in firefox and
    >> opera the input is the zero'th element of the returned array, in IE
    >> the browser throws an error if you access the zeroth element.

    >
    > And I can't duplicate that. This code:
    >
    > <script type="text/javascript">
    > function foo()
    > {
    > var dung;
    > dung=document.getElementsByName('foo')[0].value;
    > alert(dung);
    > }
    >
    > </script>
    >
    > <input type="hidden" name="foo" value="shite">
    > <button onclick="foo()">Test</button>
    >
    > When I click that button in IE7, I get - "shite". No error, no problems,
    > it gives me what I expected. The only things I changed from your
    > original code was changing Alert to alert. So, what version of IE are
    > you getting that error in? And, what is the error message?
    >


    Ie6 and 7. 'error on page'. In the status bar at the bottom.


    When I changed the variable names to make the functions NOT have the
    same name as the variables, it worked.
    The Natural Philosopher, Oct 18, 2007
    #4
  5. The Natural Philosopher

    GArlington Guest

    On 18 Oct, 11:10, The Natural Philosopher <> wrote:
    > Randy Webb wrote:
    > > The Natural Philosopher said the following on 10/18/2007 5:40 AM:
    > >> Randy Webb wrote:
    > >>> The Natural Philosopher said the following on 10/17/2007 8:33 PM:

    >
    > >>> <snip>

    >
    > >>>> That was the one bit I didn't test.;-)

    >
    > >>>> you have focussed on an obvious bug and completely failed to address
    > >>>> the actual question.

    >
    > >>> The "bug" being your total inability to write a script?

    >
    > >> I wrote it and it worked, or didnt work in IE.

    >
    > >> What I posted was a demonstrative snippet that I got wrong and didn't
    > >> test.
    > >> The point being that if you have a function and a variable with the
    > >> same name, and do a getElementsbyName on the form, in firefox and
    > >> opera the input is the zero'th element of the returned array, in IE
    > >> the browser throws an error if you access the zeroth element.

    >
    > > And I can't duplicate that. This code:

    >
    > > <script type="text/javascript">
    > > function foo()
    > > {
    > > var dung;
    > > dung=document.getElementsByName('foo')[0].value;
    > > alert(dung);
    > > }

    >
    > > </script>

    >
    > > <input type="hidden" name="foo" value="shite">
    > > <button onclick="foo()">Test</button>

    >
    > > When I click that button in IE7, I get - "shite". No error, no problems,
    > > it gives me what I expected. The only things I changed from your
    > > original code was changing Alert to alert. So, what version of IE are
    > > you getting that error in? And, what is the error message?

    >
    > Ie6 and 7. 'error on page'. In the status bar at the bottom.
    >
    > When I changed the variable names to make the functions NOT have the
    > same name as the variables, it worked.


    I can see that you are talking about the same thing not understanding
    each other...
    OP puts his/her Javasript INSIDE the body (NOT in head) before the
    input field. So when he/she runs the script
    document.getElementsByName('foo')[0] refers to the FUNCTION foo and
    generates the error trying to access attribute value which function
    WILL NOT have...
    Everybody else assumes that Javascript is included in head of the page
    and so do NOT experience any errors.
    GArlington, Oct 18, 2007
    #5
  6. The Natural Philosopher

    beegee Guest

    On Oct 17, 3:02 pm, The Natural Philosopher <> wrote:

    > I am sure there s some reason why it works in other browsers but not in
    > IE, but what is it?


    There is a bug in the implementation of getElementsByName in IE 6 and
    7. The symptoms differ but your's are most like related. Read about
    it and a fix, here:

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1843487&SiteID=1&pageid=0

    And please stop whining about javascript. Go to Yahoo User Interface
    pages and watch Crockford's video on Advanced Javascript. Right now
    you are looking at about 10% of the language and calling it crap. It
    makes you look ignorant and trollish.

    Bob
    beegee, Oct 18, 2007
    #6
  7. The Natural Philosopher

    Henry Guest

    On Oct 18, 4:03 pm, Randy Webb wrote:
    > GArlington said the following on 10/18/2007 9:51 AM:

    <snip>
    >> So when he/she runs the script document.getElementsByName('foo')[0]
    >> refers to the FUNCTION foo and generates the error trying to access
    >> attribute value which function WILL NOT have...

    >
    > No, it doesn't. The function is not executed until you click on the
    > bold text in the original, the button in the latter. And, before
    > it is dreamed about, changing it back to a bold element didn't
    > make any difference either.


    The code will not error on IE until someone puts the form elements
    into a FORM element. At that point IE augments the scope chain of the
    function that it creates from the intrinsic event attribute, and it
    places the FORM element on that augmented scope chain. Thus when the
    Identifier - foo - is resolved against this augmented scope chain an
    object on the chain above the global object is found to have a 'foo'
    property and the resulting value of - foo - is the value of that
    property of the FORM element and not the global function.

    >> Everybody else assumes that Javascript is included in head of the
    >> page and so do NOT experience any errors.

    >
    > Voodoo programming. Putting my script block before the closing body
    > tag had no impact on errors. I still don't get one.


    It certainly is an odd proposition that moving the code into the HEAD
    would make any difference.
    Henry, Oct 18, 2007
    #7
  8. GArlington wrote:
    > On 18 Oct, 11:10, The Natural Philosopher <> wrote:
    >> Randy Webb wrote:
    >>> The Natural Philosopher said the following on 10/18/2007 5:40 AM:
    >>>> Randy Webb wrote:
    >>>>> The Natural Philosopher said the following on 10/17/2007 8:33 PM:
    >>>>> <snip>
    >>>>>> That was the one bit I didn't test.;-)
    >>>>>> you have focussed on an obvious bug and completely failed to address
    >>>>>> the actual question.
    >>>>> The "bug" being your total inability to write a script?
    >>>> I wrote it and it worked, or didnt work in IE.
    >>>> What I posted was a demonstrative snippet that I got wrong and didn't
    >>>> test.
    >>>> The point being that if you have a function and a variable with the
    >>>> same name, and do a getElementsbyName on the form, in firefox and
    >>>> opera the input is the zero'th element of the returned array, in IE
    >>>> the browser throws an error if you access the zeroth element.
    >>> And I can't duplicate that. This code:
    >>> <script type="text/javascript">
    >>> function foo()
    >>> {
    >>> var dung;
    >>> dung=document.getElementsByName('foo')[0].value;
    >>> alert(dung);
    >>> }
    >>> </script>
    >>> <input type="hidden" name="foo" value="shite">
    >>> <button onclick="foo()">Test</button>
    >>> When I click that button in IE7, I get - "shite". No error, no problems,
    >>> it gives me what I expected. The only things I changed from your
    >>> original code was changing Alert to alert. So, what version of IE are
    >>> you getting that error in? And, what is the error message?

    >> Ie6 and 7. 'error on page'. In the status bar at the bottom.
    >>
    >> When I changed the variable names to make the functions NOT have the
    >> same name as the variables, it worked.

    >
    > I can see that you are talking about the same thing not understanding
    > each other...
    > OP puts his/her Javasript INSIDE the body (NOT in head) before the
    > input field. So when he/she runs the script
    > document.getElementsByName('foo')[0] refers to the FUNCTION foo and
    > generates the error trying to access attribute value which function
    > WILL NOT have...
    > Everybody else assumes that Javascript is included in head of the page
    > and so do NOT experience any errors.
    >

    Ah. You HAVE explained it. Except why it works in firefox, but not in IE6.
    The Natural Philosopher, Oct 18, 2007
    #8
  9. Henry wrote:
    > On Oct 18, 4:03 pm, Randy Webb wrote:
    >> GArlington said the following on 10/18/2007 9:51 AM:

    > <snip>
    >>> So when he/she runs the script document.getElementsByName('foo')[0]
    >>> refers to the FUNCTION foo and generates the error trying to access
    >>> attribute value which function WILL NOT have...

    >> No, it doesn't. The function is not executed until you click on the
    >> bold text in the original, the button in the latter. And, before
    >> it is dreamed about, changing it back to a bold element didn't
    >> make any difference either.

    >
    > The code will not error on IE until someone puts the form elements
    > into a FORM element. At that point IE augments the scope chain of the
    > function that it creates from the intrinsic event attribute, and it
    > places the FORM element on that augmented scope chain. Thus when the
    > Identifier - foo - is resolved against this augmented scope chain an
    > object on the chain above the global object is found to have a 'foo'
    > property and the resulting value of - foo - is the value of that
    > property of the FORM element and not the global function.
    >


    After reading that 3 times, it almost makes sense.


    >>> Everybody else assumes that Javascript is included in head of the
    >>> page and so do NOT experience any errors.

    >> Voodoo programming. Putting my script block before the closing body
    >> tag had no impact on errors. I still don't get one.

    >
    > It certainly is an odd proposition that moving the code into the HEAD
    > would make any difference.
    >

    I wouldnt know. My interest is avoiding pitfalls. Not becoming an expert
    in a language I really think is rather badly written.

    When I started, there was code that was easy to read and code that was
    hard to understand.

    Then suddenly everyone started waffling about 'structured programming'.
    After a while I realized this was an academic term for what we had all
    been doing anyway. Making code easy to read.

    The the latest bollocks was 'object oriented'. But of course with
    backwards compatiblity to procedural. Oh and lets throw typing away cots
    its too hard for numpties.

    Result is a fucking plate of spaghetti where to change three bytes in a
    browser takes in interpreted variable name with more dots than a
    golfball covered in brackets and completely impenetrable, since its
    scope is implementation dependent, and, worse depends on where it sits
    in some HTML as well.

    I am coming to realise that Javascript is possibly the worst language I
    have ever had to program in.
    The Natural Philosopher, Oct 18, 2007
    #9
  10. beegee wrote:
    > On Oct 17, 3:02 pm, The Natural Philosopher <> wrote:
    >
    >> I am sure there s some reason why it works in other browsers but not in
    >> IE, but what is it?

    >
    > There is a bug in the implementation of getElementsByName in IE 6 and
    > 7. The symptoms differ but your's are most like related. Read about
    > it and a fix, here:
    >
    > http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1843487&SiteID=1&pageid=0
    >
    > And please stop whining about javascript. Go to Yahoo User Interface
    > pages and watch Crockford's video on Advanced Javascript. Right now
    > you are looking at about 10% of the language and calling it crap. It
    > makes you look ignorant and trollish.
    >


    I'll whinge if I want to ;-)

    I AM ignorant of javascript. But not of programming in general. All I
    can say is that is is the worst language I've ever used from a personal
    point of view.

    And Microsnot has made a pigs ear of implementing it.

    > Bob
    >
    The Natural Philosopher, Oct 18, 2007
    #10
  11. The Natural Philosopher

    Doug Miller Guest

    In article <>, The Natural Philosopher <> wrote:
    >
    >I am coming to realise that Javascript is possibly the worst language I
    >have ever had to program in.


    Never had any experience with RPG or LISP, I see... <g>

    --
    Regards,
    Doug Miller (alphageek at milmac dot com)

    It's time to throw all their damned tea in the harbor again.
    Doug Miller, Oct 18, 2007
    #11
  12. The Natural Philosopher

    Henry Guest

    On Oct 18, 6:11 pm, The Natural Philosopher wrote:
    > Henry wrote:

    <snip>
    >> The code will not error on IE until someone puts the form
    >> elements into a FORM element. At that point IE augments the
    >> scope chain of the function that it creates from the
    >> intrinsic event attribute, and it places the FORM element
    >> on that augmented scope chain. Thus when the Identifier -
    >> foo - is resolved against this augmented scope chain an
    >> object on the chain above the global object is found to
    >> have a 'foo' property and the resulting value of - foo -
    >> is the value of that property of the FORM element and not
    >> the global function.

    >
    > After reading that 3 times, it almost makes sense.
    >
    >>>> Everybody else assumes that Javascript is included in head
    >>>> of the page and so do NOT experience any errors.
    >>> Voodoo programming. Putting my script block before the

    >
    >>> closing body tag had no impact on errors. I still don't
    >>> get one.

    >
    >> It certainly is an odd proposition that moving the code into
    >> the HEAD would make any difference.

    >
    > I wouldnt know. My interest is avoiding pitfalls.


    That also seems odd, as you have so far reacted to most of the advice
    you have been given here by disregarding it (often with the defence
    that you know better).

    > Not becoming an expert in a language I really think is
    > rather badly written.


    Some of the advice you were given was that you would be better off
    writing your project with server-side code, you replied that you knew
    better.

    > When I started, there was code that was easy to read and
    > code that was hard to understand.
    >
    > Then suddenly everyone started waffling about 'structured
    > programming'. After a while I realized this was an academic
    > term for what we had all been doing anyway. Making code easy
    > to read.
    >
    > The the latest bollocks was 'object oriented'. But of course
    > with backwards compatiblity to procedural. Oh and lets throw
    > typing away cots its too hard for numpties.


    Loose typing is generally harder to program than strong typing. It
    shifts responsibility for keeping track of typing from a complier to
    the programmer and so requires a higher level of discipline from the
    programmer if they don't what to end up not understanding what their
    own code is doing.

    > Result is a fucking plate of spaghetti where to change three
    > bytes in a browser


    You don't "change bytes" in javascript.

    > takes in interpreted variable name with more dots than a
    > golfball covered in brackets and completely impenetrable,
    > since its scope is implementation dependent, and, worse
    > depends on where it sits in some HTML as well.


    Says who? The snippets of your code that you have posted are already
    bizarre; who uses - getElementsByName - to reference a form control?
    It seems that you are making a rod for your own back. And have already
    spent any sympathy you may have received for you position.

    > I am coming to realise that Javascript is possibly the worst
    > language I have ever had to program in.


    Then don't. It is not compulsory.
    Henry, Oct 18, 2007
    #12
  13. The Natural Philosopher

    David Cox Guest

    "The Natural Philosopher" <> wrote in message
    news:...
    > beegee wrote:
    >> On Oct 17, 3:02 pm, The Natural Philosopher <> wrote:
    >>
    >>> I am sure there s some reason why it works in other browsers but not in
    >>> IE, but what is it?

    >>
    >> There is a bug in the implementation of getElementsByName in IE 6 and
    >> 7. The symptoms differ but your's are most like related. Read about
    >> it and a fix, here:
    >>
    >> http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1843487&SiteID=1&pageid=0
    >>
    >> And please stop whining about javascript. Go to Yahoo User Interface
    >> pages and watch Crockford's video on Advanced Javascript. Right now
    >> you are looking at about 10% of the language and calling it crap. It
    >> makes you look ignorant and trollish.
    >>

    >
    > I'll whinge if I want to ;-)
    >
    > I AM ignorant of javascript. But not of programming in general. All I can
    > say is that is is the worst language I've ever used from a personal point
    > of view.
    >


    Right there with you, but somehow I don't think they are going to fix it
    just for us..

    > And Microsnot has made a pigs ear of implementing it.
    >
    >
    >> Bob
    >>
    David Cox, Oct 19, 2007
    #13
  14. Doug Miller wrote:
    > In article <>, The Natural Philosopher <> wrote:
    >> I am coming to realise that Javascript is possibly the worst language I
    >> have ever had to program in.

    >
    > Never had any experience with RPG or LISP, I see... <g>
    >

    RPG a very little.

    I took one look at LISP and decided that a man has only so many years in
    his life, and devoting them to LISP was not a way I chose to fill mine.

    FORTH is anther one. But at least it has an excuse. Nothing compiles to
    a smaller piece of code than FORTH.
    The Natural Philosopher, Oct 19, 2007
    #14
  15. Henry wrote:
    > On Oct 18, 6:11 pm, The Natural Philosopher wrote:
    >> Henry wrote:

    > <snip>
    >>> The code will not error on IE until someone puts the form
    >>> elements into a FORM element. At that point IE augments the
    >>> scope chain of the function that it creates from the
    >>> intrinsic event attribute, and it places the FORM element
    >>> on that augmented scope chain. Thus when the Identifier -
    >>> foo - is resolved against this augmented scope chain an
    >>> object on the chain above the global object is found to
    >>> have a 'foo' property and the resulting value of - foo -
    >>> is the value of that property of the FORM element and not
    >>> the global function.

    >> After reading that 3 times, it almost makes sense.
    >>
    >>>>> Everybody else assumes that Javascript is included in head
    >>>>> of the page and so do NOT experience any errors.
    >>>> Voodoo programming. Putting my script block before the
    >>>> closing body tag had no impact on errors. I still don't
    >>>> get one.
    >>> It certainly is an odd proposition that moving the code into
    >>> the HEAD would make any difference.

    >> I wouldnt know. My interest is avoiding pitfalls.

    >
    > That also seems odd, as you have so far reacted to most of the advice
    > you have been given here by disregarding it (often with the defence
    > that you know better).
    >
    >> Not becoming an expert in a language I really think is
    >> rather badly written.

    >
    > Some of the advice you were given was that you would be better off
    > writing your project with server-side code, you replied that you knew
    > better.
    >


    I do know what i want to achieve: Ive had advice ranging fom 'do it
    server side ' (most of it is) to 'do it all in javascrip' which is as I
    am coming to understand, bad advice.

    >> When I started, there was code that was easy to read and
    >> code that was hard to understand.
    >>
    >> Then suddenly everyone started waffling about 'structured
    >> programming'. After a while I realized this was an academic
    >> term for what we had all been doing anyway. Making code easy
    >> to read.
    >>
    >> The the latest bollocks was 'object oriented'. But of course
    >> with backwards compatiblity to procedural. Oh and lets throw
    >> typing away cots its too hard for numpties.

    >
    > Loose typing is generally harder to program than strong typing. It
    > shifts responsibility for keeping track of typing from a complier to
    > the programmer and so requires a higher level of discipline from the
    > programmer if they don't what to end up not understanding what their
    > own code is doing.


    Precisely.
    >
    >> Result is a fucking plate of spaghetti where to change three
    >> bytes in a browser

    >
    > You don't "change bytes" in javascript.


    All programs ever do is 'change bytes' mate. Or did that one pass you by?

    The soundest comment I ever received from one of the tighest machine
    code programmers ever was 'languages schamguages: its all just bits, in
    silicon'

    Advice that the language junkies fail to heed.

    A programming language is a *tool* to organize a sequence of inputs into
    a unique and specified series of outputs. To do that it reads bytes, and
    changes bytes, and outputs bytes (or bits or words) to something humans
    interact with.

    This oe is in my opinion a singularly bad one: its fashionably object
    oriented, but its been cobbled together and it has no systematic
    coherence: At lest with something like C or Fortran, there existed a
    book or set of standards which defined the language.


    >
    >> takes in interpreted variable name with more dots than a
    >> golfball covered in brackets and completely impenetrable,
    >> since its scope is implementation dependent, and, worse
    >> depends on where it sits in some HTML as well.

    >
    > Says who? The snippets of your code that you have posted are already
    > bizarre; who uses - getElementsByName - to reference a form control?


    I do. I could have used id I guess..

    > It seems that you are making a rod for your own back. And have already
    > spent any sympathy you may have received for you position.
    >
    >> I am coming to realise that Javascript is possibly the worst
    >> language I have ever had to program in.

    >
    > Then don't. It is not compulsory.
    >

    Sadly, if you want to get a browser to do tricks, it is.
    The Natural Philosopher, Oct 19, 2007
    #15
  16. David Cox wrote:
    > "The Natural Philosopher" <> wrote in message
    > news:...
    >> beegee wrote:
    >>> On Oct 17, 3:02 pm, The Natural Philosopher <> wrote:
    >>>
    >>>> I am sure there s some reason why it works in other browsers but not in
    >>>> IE, but what is it?
    >>> There is a bug in the implementation of getElementsByName in IE 6 and
    >>> 7. The symptoms differ but your's are most like related. Read about
    >>> it and a fix, here:
    >>>
    >>> http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1843487&SiteID=1&pageid=0
    >>>
    >>> And please stop whining about javascript. Go to Yahoo User Interface
    >>> pages and watch Crockford's video on Advanced Javascript. Right now
    >>> you are looking at about 10% of the language and calling it crap. It
    >>> makes you look ignorant and trollish.
    >>>

    >> I'll whinge if I want to ;-)
    >>
    >> I AM ignorant of javascript. But not of programming in general. All I can
    >> say is that is is the worst language I've ever used from a personal point
    >> of view.
    >>

    >
    > Right there with you, but somehow I don't think they are going to fix it
    > just for us..
    >


    No. I begin to see what my friend said when he muttered darkly -
    'Javascrpt: Active X - XML - sod that - I leave that to the geeks that
    work for me: broswr development is a nightmare. Its no good implementing
    to the specifications - none of the other browsers do.'

    ;-)

    >> And Microsnot has made a pigs ear of implementing it.
    >>
    >>
    >>> Bob
    >>>

    >
    >
    The Natural Philosopher, Oct 19, 2007
    #16
  17. The Natural Philosopher

    David Mark Guest

    On Oct 18, 11:38 pm, The Natural Philosopher <> wrote:
    > Henry wrote:

    [snip]
    >
    > > Says who? The snippets of your code that you have posted are already
    > > bizarre; who uses - getElementsByName - to reference a form control?

    >
    > I do. I could have used id I guess..
    >


    And that would be silly as well. Why don't you try learning about DOM
    implementations before attempting to manipulate them with JavaScript?
    That will save you a lot of future frustration.
    David Mark, Oct 19, 2007
    #17
  18. On Oct 18, 10:15 am, The Natural Philosopher <> wrote:
    > beegee wrote:
    > > On Oct 17, 3:02 pm, The Natural Philosopher <> wrote:

    >
    > >> I am sure there s some reason why it works in other browsers but not in
    > >> IE, but what is it?

    >
    > > There is a bug in the implementation of getElementsByName in IE 6 and
    > > 7. The symptoms differ but your's are most like related. Read about
    > > it and a fix, here:

    >
    > >http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1843487&SiteID=...

    >
    > > And please stop whining about javascript. Go to Yahoo User Interface
    > > pages and watch Crockford's video on Advanced Javascript. Right now
    > > you are looking at about 10% of the language and calling it crap. It
    > > makes you look ignorant and trollish.

    >
    > I'll whinge if I want to ;-)
    >
    > I AM ignorant of javascript. But not of programming in general. All I
    > can say is that is is the worst language I've ever used from a personal
    > point of view.


    You post to comp.lang.javascript asking for help with an untested
    example. That makes it difficult for someone to understand your
    problem.

    You berated a respondent, who was generously volunteering his time,
    for pointing out a bug in your untested example where the respondent
    reasonably assumed you intended what you posted.

    In self admitted ignorance, you berate the language that is the
    subject of this group. The majority of regular posters to the group
    understand and like the language. It is better than you think. They
    have also read more than enough complaints from ignoramuses like you
    about the language before and don't really want to hear it again. You
    have not exactly won over anyone's affection with this sort of ranting
    and reduced your chance of receiving help.

    Sure you are able to vent or say anything you want on
    comp.lang.javascript as it is a public group; however, if you want to
    vent in public don't expect any help from the regulars. You will
    likely be ignored.

    My advice is to either apologize or change your screen name and start
    again recognizing that the people here are generously volunteering
    their time to help you. That is a really amazing thing they are
    willing to do for you. They don't know you and have better things to
    do I am sure.

    Peter
    Peter Michaux, Oct 19, 2007
    #18
  19. The Natural Philosopher

    Tim Streater Guest

    In article <>,
    The Natural Philosopher <> wrote:

    > Henry wrote:
    > > On Oct 18, 4:03 pm, Randy Webb wrote:
    > >> GArlington said the following on 10/18/2007 9:51 AM:

    > > <snip>
    > >>> So when he/she runs the script document.getElementsByName('foo')[0]
    > >>> refers to the FUNCTION foo and generates the error trying to access
    > >>> attribute value which function WILL NOT have...
    > >> No, it doesn't. The function is not executed until you click on the
    > >> bold text in the original, the button in the latter. And, before
    > >> it is dreamed about, changing it back to a bold element didn't
    > >> make any difference either.

    > >
    > > The code will not error on IE until someone puts the form elements
    > > into a FORM element. At that point IE augments the scope chain of the
    > > function that it creates from the intrinsic event attribute, and it
    > > places the FORM element on that augmented scope chain. Thus when the
    > > Identifier - foo - is resolved against this augmented scope chain an
    > > object on the chain above the global object is found to have a 'foo'
    > > property and the resulting value of - foo - is the value of that
    > > property of the FORM element and not the global function.
    > >

    >
    > After reading that 3 times, it almost makes sense.
    >
    >
    > >>> Everybody else assumes that Javascript is included in head of the
    > >>> page and so do NOT experience any errors.
    > >> Voodoo programming. Putting my script block before the closing body
    > >> tag had no impact on errors. I still don't get one.

    > >
    > > It certainly is an odd proposition that moving the code into the HEAD
    > > would make any difference.
    > >

    > I wouldnt know. My interest is avoiding pitfalls. Not becoming an expert
    > in a language I really think is rather badly written.
    >
    > When I started, there was code that was easy to read and code that was
    > hard to understand.
    >
    > Then suddenly everyone started waffling about 'structured programming'.
    > After a while I realized this was an academic term for what we had all
    > been doing anyway. Making code easy to read.


    Well, to be fair, not everyone had been doing that. It takes discipline
    to make code easy to read, and easy to maintain, particularly if you
    expect it to be part of a bigger package that will be handed over to
    others to look after. While at CERN, I once saw a FORTRAN subroutine
    written by a physicist for an analysis program. It was 50 pages of code,
    when printed out on the fanfold paper of the time.

    I had little confidence that it was fit for purpose.

    Hardest part is prevent programmers being too clever and getting them to
    document what they are doing.

    > The the latest bollocks was 'object oriented'. But of course with
    > backwards compatiblity to procedural. Oh and lets throw typing away cots
    > its too hard for numpties.
    >
    > Result is a fucking plate of spaghetti where to change three bytes in a
    > browser takes in interpreted variable name with more dots than a
    > golfball covered in brackets and completely impenetrable, since its
    > scope is implementation dependent, and, worse depends on where it sits
    > in some HTML as well.
    >
    > I am coming to realise that Javascript is possibly the worst language I
    > have ever had to program in.


    Your post made me chuckle and its no bad thing for pompous language
    types to be needled from time to time. But I don't think JS *quite*
    deserves this level of opprobrium.

    Perl, on the other hand, does. That's a much shittier language than JS,
    so feel free to mosey on over to their NG.

    And remember: poor programmers can write FORTRAN in any language.
    Tim Streater, Oct 19, 2007
    #19
  20. The Natural Philosopher

    Tim Streater Guest

    In article <>,
    The Natural Philosopher <> wrote:

    [snip]

    > The soundest comment I ever received from one of the tighest machine
    > code programmers ever was 'languages schamguages: its all just bits, in
    > silicon'


    Has this guy ever written in anything other than machine code? If not, I
    wouldn't pay any attention to him whatever.
    Tim Streater, Oct 19, 2007
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pep
    Replies:
    1
    Views:
    2,200
    Stefan Siegl
    Oct 7, 2005
  2. grahamo
    Replies:
    2
    Views:
    366
    Sharad Kala
    Feb 25, 2004
  3. Steven T. Hatton

    #include verse class class_name

    Steven T. Hatton, Apr 8, 2004, in forum: C++
    Replies:
    14
    Views:
    591
    Steven T. Hatton
    Apr 10, 2004
  4. HMM and CRF Package

    , Jul 24, 2012, in forum: Python
    Replies:
    4
    Views:
    296
  5. Kenny McCormack

    For those who like quoting chapter and verse...

    Kenny McCormack, Feb 26, 2013, in forum: C Programming
    Replies:
    8
    Views:
    269
    Nick Keighley
    Mar 9, 2013
Loading...

Share This Page