Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #11766 > unrolled thread
| Started by | "Tom de Neef" <tdeneef@qolor.nl> |
|---|---|
| First post | 2012-02-15 00:09 +0100 |
| Last post | 2012-02-15 16:46 -0800 |
| Articles | 11 — 6 participants |
Back to article view | Back to comp.lang.javascript
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
| From | "Tom de Neef" <tdeneef@qolor.nl> |
|---|---|
| Date | 2012-02-15 00:09 +0100 |
| Subject | body onload not executed |
| Message-ID | <4f3ae9c5$0$6918$e4fe514c@news2.news.xs4all.nl> |
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? TIA Tom
[toc] | [next] | [standalone]
| From | "Evertjan." <exjxw.hannivoort@interxnl.net> |
|---|---|
| Date | 2012-02-14 23:29 +0000 |
| Message-ID | <Xns9FFA4EC91084eejj99@194.109.133.133> |
| In reply to | #11766 |
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 ")"
// much more code
function a(){
alert('ok');
};
</script>
<body onload='a();'>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | "Tom de Neef" <tdeneef@qolor.nl> |
|---|---|
| Date | 2012-02-15 09:26 +0100 |
| Message-ID | <4f3b6c2b$0$6854$e4fe514c@news2.news.xs4all.nl> |
| In reply to | #11767 |
"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.
I have now checked the attributes and properties of the body element: onload
is empty.
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?
Tom
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2012-02-15 09:08 +0000 |
| Message-ID | <4f3b761c$0$29584$a8266bb1@newsreader.readnews.com> |
| In reply to | #11771 |
On Wed, 15 Feb 2012 09:26:19 +0100, Tom de Neef wrote: > 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? Tom Search through all the js files that the site calls in to see if anything is changing the onload event handler of the body element. You may have to spend some time identifying and grabbing all the script files. If you find that multiple scripts change (or try to change) the onload handling, you'll need to then identify which one is the culprit. Rgds Denis McMahon
[toc] | [prev] | [next] | [standalone]
| From | "Tom de Neef" <tdeneef@qolor.nl> |
|---|---|
| Date | 2012-02-15 10:26 +0100 |
| Message-ID | <4f3b7a38$0$6930$e4fe514c@news2.news.xs4all.nl> |
| In reply to | #11772 |
"Denis McMahon" <denismfmcmahon@gmail.com> schreef in bericht news:4f3b761c$0$29584$a8266bb1@newsreader.readnews.com... > On Wed, 15 Feb 2012 09:26:19 +0100, Tom de Neef wrote: > >> 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? Tom > > Search through all the js files that the site calls in to see if anything > is changing the onload event handler of the body element. > > You may have to spend some time identifying and grabbing all the script > files. > > If you find that multiple scripts change (or try to change) the onload > handling, you'll need to then identify which one is the culprit. Hmm. I try to do someone a favour ;-) Anyway, if that's what needs to be done, I'll do it. I was hoping there would be a way to test if body.onload is assigned at regular points, say after a script has been loaded. But without modifying the html source. Tom
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2012-02-15 13:48 +0000 |
| Message-ID | <4f3bb79f$0$29703$a8266bb1@newsreader.readnews.com> |
| In reply to | #11773 |
On Wed, 15 Feb 2012 10:26:15 +0100, Tom de Neef wrote: > "Denis McMahon" <denismfmcmahon@gmail.com> schreef in bericht > news:4f3b761c$0$29584$a8266bb1@newsreader.readnews.com... >> On Wed, 15 Feb 2012 09:26:19 +0100, Tom de Neef wrote: >> >>> 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? Tom >> >> Search through all the js files that the site calls in to see if >> anything is changing the onload event handler of the body element. >> >> You may have to spend some time identifying and grabbing all the script >> files. >> >> If you find that multiple scripts change (or try to change) the onload >> handling, you'll need to then identify which one is the culprit. > > Hmm. I try to do someone a favour ;-) Anyway, if that's what needs to be > done, I'll do it. I was hoping there would be a way to test if > body.onload is assigned at regular points, say after a script has been > loaded. But without modifying the html source. Hmm, could try downloading the page in ff, then running a grep over any js in the "files" directory. Or post the url of the web page concerned and see if anyone is bored enough to look at it. ;) Rgds Denis McMahon
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exjxw.hannivoort@interxnl.net> |
|---|---|
| Date | 2012-02-15 10:33 +0000 |
| Message-ID | <Xns9FFA7585A8360eejj99@194.109.133.133> |
| In reply to | #11771 |
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)
[toc] | [prev] | [next] | [standalone]
| From | Hans-Georg Michna <hans-georgNoEmailPlease@michna.com> |
|---|---|
| Date | 2012-02-15 17:56 +0100 |
| Message-ID | <3qonj7te7trbp2jp6huf8ts94jn4ggqhdq@4ax.com> |
| In reply to | #11766 |
On Wed, 15 Feb 2012 00:09:57 +0100, Tom de Neef wrote: >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? >TIA >Tom Assuming that some other script fiddles with the onload handler of the body element, a very simple workaround would be to put the call into a script element just before the closing body tag, thus: ... <script>getChartInfo();</script> </body> </html> Hans-Georg
[toc] | [prev] | [next] | [standalone]
| From | "Tom de Neef" <tdeneef@qolor.nl> |
|---|---|
| Date | 2012-02-17 14:45 +0100 |
| Message-ID | <4f3e5a02$0$6925$e4fe514c@news2.news.xs4all.nl> |
| In reply to | #11781 |
"Hans-Georg Michna" <hans-georgNoEmailPlease@michna.com> schreef in bericht news:3qonj7te7trbp2jp6huf8ts94jn4ggqhdq@4ax.com... > On Wed, 15 Feb 2012 00:09:57 +0100, Tom de Neef wrote: > > Assuming that some other script fiddles with the onload handler > of the body element, a very simple workaround would be to put > the call into a script element just before the closing body tag, > thus: > > ... > <script>getChartInfo();</script> > </body> > </html> I have followed this approach and it works fine. Thank you. I have also checked all the script files loaded by the page. And indeed there is one that seems to change onload. (A Google file it seems, aimed at measuring/optimizing map loading.) It is hard to tell what it does with its scrambled layout. When the client removed this js file, the problem was over. But your approach looks healhtier in this environment. Tom
[toc] | [prev] | [next] | [standalone]
| From | Dr J R Stockton <reply1207@merlyn.demon.co.uk> |
|---|---|
| Date | 2012-02-15 20:37 +0000 |
| Message-ID | <kx12lHJTeBPPFwo7@invalid.uk.co.demon.merlyn.invalid> |
| In reply to | #11766 |
In comp.lang.javascript message <4f3ae9c5$0$6918$e4fe514c@news2.news.xs4
all.nl>, Wed, 15 Feb 2012 00:09:57, Tom de Neef <tdeneef@qolor.nl>
posted:
>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()">.
Try <body onload="alert(12345);getChartInfo()">.
And scan all files, HTML and JS, for any other occurrences of onload
which might have overridden that.
If you have no more than treble-checked the spelling of getChartInfo,
try a few more times.
Scan the files for any possible assignment to getChartInfo.
Replace getChartInfo() by qwerty() in body onload, and provide
function qwerty() { alert(98765) } to see if that works.
Also : I'd starting testing a function with a button that executed the
function provided in a <script> element. It seemed OK, so I tidied the
code itself and changed the element to <script type-"text/javasript">.
It ceased to work, with nothing appearing in the Error Console.
Hint - although your English seems perfect, your keying is not always
quite so.
> ...
>In a test environmet
> ...
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <http://www.merlyn.demon.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)
[toc] | [prev] | [next] | [standalone]
| From | Gene Wirchenko <genew@ocis.net> |
|---|---|
| Date | 2012-02-15 16:46 -0800 |
| Message-ID | <93koj7ll3dk5a6u5rg2s9i49nq774djlh6@4ax.com> |
| In reply to | #11806 |
On Wed, 15 Feb 2012 20:37:39 +0000, Dr J R Stockton
<reply1207@merlyn.demon.co.uk> wrote:
>In comp.lang.javascript message <4f3ae9c5$0$6918$e4fe514c@news2.news.xs4
>all.nl>, Wed, 15 Feb 2012 00:09:57, Tom de Neef <tdeneef@qolor.nl>
>posted:
>
>>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()">.
>
>Try <body onload="alert(12345);getChartInfo()">.
>
>And scan all files, HTML and JS, for any other occurrences of onload
>which might have overridden that.
Try commenting out code to isolate what is giving the trouble.
I just had a problem today with code that broke when it should
not have. Divide and conquer. Somehow, a segment of code got munged.
It is supposed to be a duplicate of another section so I just copied
from the other section, and bang: page working again.
It is not true that the language is out to get you, because TODO:
Come up with reason.
[snip]
Sincerely,
Gene Wirchenko
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web