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


Groups > comp.lang.javascript > #27365

Re: XMLHttpRequest and Google Chrome

From Robbie Brown <rob@example.com>
Newsgroups comp.lang.javascript
Subject Re: XMLHttpRequest and Google Chrome
Date 2015-04-13 20:11 +0100
Organization A noiseless patient Spider
Message-ID <mgh4bb$nlq$1@dont-email.me> (permalink)
References (7 earlier) <mggock$rt7$1@solani.org> <mggqp5$cu6$1@dont-email.me> <130420151829307070%timstreater@greenbee.net> <mgh03o$3lk$1@dont-email.me> <130420151934150171%timstreater@greenbee.net>

Show all headers | View raw


On 13/04/15 19:34, Tim Streater wrote:
> In article <mgh03o$3lk$1@dont-email.me>, Robbie Brown <rob@example.com>
> wrote:
>
>> On 13/04/15 18:29, Tim Streater wrote:
>
>> OK, I did a test.
>>
>> In <head> I have
>>
>> <script type="text/javascript">>
>>    window.onload = getCart();
>> </script>
>>
>> In getCart() I put an alert as the first line
>>
>> (incidentally getCart() is in a file that is referenced thusly in <head>
>> <script type="text/javascript" src="/javascript/cart.js"></script>
>> before the call obviously)
>>
>> alert("hello");
>>
>> when I load any page in Firefox (and occasionally in Chrome) I get
>> "hello" *before* the page is displayed
>
> IOW before it is loaded.
>
>> if I change <head>
>>
>> <script type="text/javascript">
>>    window.onload = getCart;
>> </script>
>>
>> The function doesn't get called, I get no "hello"
>> This is the same in all my browsers. I have no idea why as you and
>> others say that getCart should work, it simply doesn't. I'm not making
>> it up, it doesn't execute, I'm not mistaken, so, obviously something
>> is still missing.
>
> But this is the point. You don't want getCart to be executed when the
> following code is encountered by the browser:
>
>> <script type="text/javascript">
>>    window.onload = getCart;
>> </script>
>
> That is too soon. The browser will likely not yet have seen and parsed
> everything, or completed its tasks. The page, IOW, is not yet ready.
> You want it to be executed *later*, when the page *is* ready (i.e.
> loaded). What you are telling the browser with:
>
>   window.onload = getCart;
> is: "Please note that getCart is the function I want to be run when the
> onload is complete". If you say:
>
>   window.onload = getCart ();
>
> you are saying to the browser: "Please run getCart *now* and assign its
> return result as the function to be run *later* when the onload is
> complete". But as someone noted, getCart doesn't return anything
> anyway.
>
>
> Now - using:
>
>   window.onload = getCart;
> is anything reported in any browser's error console?
>

Er, yes, I get an error from the google analytics stuff ...erk

Failed to load resource: the server responded with a status of 404 not 
found  http://www.google-analytics.com/analytics.js

but this happens regardless, yet analytics is obviously working because 
I can see the daily totals and live view works perfectly ... oh jeez, 
this is becoming a mess ... but no, apart from the apparent anomalous 
analytics error I get nothing


-- 
Not floundering ... just fishing

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


Thread

XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-12 19:36 +0100
  Re: XMLHttpRequest and Google Chrome JJ <jj4public@vfemail.net> - 2015-04-13 12:33 +0700
    Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 07:41 +0100
  Re: XMLHttpRequest and Google Chrome Martin Honnen <mahotrash@yahoo.de> - 2015-04-13 11:30 +0200
    Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 11:50 +0100
      Re: XMLHttpRequest and Google Chrome Tim Streater <timstreater@greenbee.net> - 2015-04-13 13:17 +0100
        Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 13:34 +0100
          Re: XMLHttpRequest and Google Chrome Tim Streater <timstreater@greenbee.net> - 2015-04-13 14:26 +0100
          Re: XMLHttpRequest and Google Chrome Martin Honnen <mahotrash@yahoo.de> - 2015-04-13 16:15 +0200
            Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 16:03 +0100
              Re: XMLHttpRequest and Google Chrome Martin Honnen <mahotrash@yahoo.de> - 2015-04-13 19:26 +0200
                Re: XMLHttpRequest and Google Chrome "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-04-13 20:23 +0200
          Re: XMLHttpRequest and Google Chrome Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-04-13 15:50 +0100
            Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 16:10 +0100
              Re: XMLHttpRequest and Google Chrome "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-04-13 17:46 +0200
                Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 17:28 +0100
                Re: XMLHttpRequest and Google Chrome "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-04-13 19:14 +0200
                Re: XMLHttpRequest and Google Chrome Tim Streater <timstreater@greenbee.net> - 2015-04-13 18:29 +0100
                Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 18:59 +0100
                Re: XMLHttpRequest and Google Chrome "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-04-13 20:29 +0200
                Re: XMLHttpRequest and Google Chrome Tim Streater <timstreater@greenbee.net> - 2015-04-13 19:34 +0100
                Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 20:11 +0100
                Re: XMLHttpRequest and Google Chrome "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-04-13 20:44 +0200
                Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 20:21 +0100
                Re: XMLHttpRequest and Google Chrome Denis McMahon <denismfmcmahon@gmail.com> - 2015-04-14 12:43 +0000
                Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-14 14:50 +0100
                Re: XMLHttpRequest and Google Chrome Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-14 22:51 +0200
                Re: XMLHttpRequest and Google Chrome Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-04-13 22:28 +0200
  Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-13 19:23 +0100
    Re: XMLHttpRequest and Google Chrome Tim Streater <timstreater@greenbee.net> - 2015-04-13 19:38 +0100
  Re: XMLHttpRequest and Google Chrome "Leonardo Azpurua" <leonardo@exmvps.org> - 2015-04-13 17:36 -0430
  Re: XMLHttpRequest and Google Chrome Robbie Brown <rob@example.com> - 2015-04-14 11:35 +0100
  Re: XMLHttpRequest and Google Chrome Denis McMahon <denismfmcmahon@gmail.com> - 2015-04-14 11:37 +0000

csiph-web