Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #11774

Re: body onload not executed

Newsgroups comp.lang.javascript
Subject Re: body onload not executed
From "Evertjan." <exjxw.hannivoort@interxnl.net>
References <4f3ae9c5$0$6918$e4fe514c@news2.news.xs4all.nl> <Xns9FFA4EC91084eejj99@194.109.133.133> <4f3b6c2b$0$6854$e4fe514c@news2.news.xs4all.nl>
Message-ID <Xns9FFA7585A8360eejj99@194.109.133.133> (permalink)
Date 2012-02-15 10:33 +0000

Show all headers | View raw


Tom de Neef wrote on 15 feb 2012 in comp.lang.javascript:

> "Evertjan." <exjxw.hannivoort@interxnl.net> schreef in bericht 
> news:Xns9FFA4EC91084eejj99@194.109.133.133...
>> Tom de Neef wrote on 15 feb 2012 in comp.lang.javascript:
>>
>>> I help someone with a XHTML site. It loads dozens of JavaScript
>>> files and a lot of processing is going on during the loading of a
>>> page. The script I am interested in is called via <body
>>> onload="getChartInfo()">. The dubugger (in IE, FF or Chrome) tells
>>> me that the necessary js file has been loaded. But a breakpoint at
>>> the start of the function body is never reached.
>>> In a test environmet - where I have removed all the other scripts -
>>> things work fine.
>>> There is only one <body> tag and the page is presented in the
>>> browser. I would say that the onload event must have occurred. What
>>> is a likely reason that the event handler is not called?
>>
>> When JS has encountered an error,
>> preventing correct parsing of getChartInfo() ?
>>
>>
>> Try:
>> <script type='text/javascript'>
>> blah(; // missing ")"
>> function a(){alert('ok');};
>> </script>
>> <body onload='a();'>
>>
> 
> When I introduce an error like that IE debugger will report a syntax
> error when loading the page.
> In my case no errors are reported.

Why didn't you tell about which browser and what errors?

On my Chrome my example acts like you posted.

> I have now checked the attributes and properties of the body element:
> onload is empty.

What does "empty" mean? Returning "null"?

Chrome & IE9:

=====================
<body>

<script type='text/javascript'>
alert(body.onload); // null
</script>
=====================

=====================
<body onload='alert(1)'>

<script type='text/javascript'>
alert(body.onload); // function onload(**) {alert(1)}
</script>
=====================
** Chrome: event


> That is the status when the page has been loaded. I can not check the
> status during the processing of all the scripts.
> The html surely contains <body onload="getChartInfo()">.
> Can it be that one of the scripts 'removes' the body.onload assignment
> and if so what would I have to do to find out where it happens?

Simple debugging with remarking /*....*/ of parts of the script.

Simple ancient debugging gets you to the error more reliable,
be it slowly, than this modern js-console thing, as error generation is 
also done by software that might in itself be affected by the error.. 

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

body onload not executed "Tom de Neef" <tdeneef@qolor.nl> - 2012-02-15 00:09 +0100
  Re: body onload not executed "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-02-14 23:29 +0000
    Re: body onload not executed "Tom de Neef" <tdeneef@qolor.nl> - 2012-02-15 09:26 +0100
      Re: body onload not executed Denis McMahon <denismfmcmahon@gmail.com> - 2012-02-15 09:08 +0000
        Re: body onload not executed "Tom de Neef" <tdeneef@qolor.nl> - 2012-02-15 10:26 +0100
          Re: body onload not executed Denis McMahon <denismfmcmahon@gmail.com> - 2012-02-15 13:48 +0000
      Re: body onload not executed "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-02-15 10:33 +0000
  Re: body onload not executed Hans-Georg Michna <hans-georgNoEmailPlease@michna.com> - 2012-02-15 17:56 +0100
    Re: body onload not executed "Tom de Neef" <tdeneef@qolor.nl> - 2012-02-17 14:45 +0100
  Re: body onload not executed Dr J R Stockton <reply1207@merlyn.demon.co.uk> - 2012-02-15 20:37 +0000
    Re: body onload not executed Gene Wirchenko <genew@ocis.net> - 2012-02-15 16:46 -0800

csiph-web