[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Flow of execution

emf

4/10/2016 9:59:00 AM

If I add an alert at the end of the following function (from
hmf.neocities.org/ix/is5.html):

window.onload = function () {
"use strict";
document.getElementById("start").onclick = function () {
requestFullScreen();
init();
alert("!"); // added alert
};
};

I would expect that when the Start button is clicked first the
requestFullScreen() would execute, then the init(), and when that one
has finished executing, the alert would come up. But obviously my
reasoning is wrong, because the alert appears immediately after the html
is loaded.

I would greatly appreciate an explanation of the flow of execution in
JavaScript.

Thanks,

Eustace

--
Eye exercises
http://emf.neocities.org/ix...
13 Answers

Thomas 'PointedEars' Lahn

4/10/2016 11:46:00 AM

0

emf wrote:

> If I add an alert at the end of the following function (from
> hmf.neocities.org/ix/is5.html):
>
> window.onload = function () {
> "use strict";
> document.getElementById("start").onclick = function () {
> requestFullScreen();
> init();
> alert("!"); // added alert
> };
> };
>
> [â?¦] the alert appears immediately after the html is loaded.

It does not. In the *actual* code, either the braces are in the wrong place
or there is an extra alert(â?¦) call. But the part-URI that you gave is 404-
compatible.

> I would greatly appreciate an explanation of the flow of execution in
> JavaScript.

This has nothing to do with JavaScript.

And: No name, no cookies.

--
PointedEars
FAQ: <http://PointedEars.... | SVN: <http://PointedEars.de...
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-...
Please do not cc me. / Bitte keine Kopien per E-Mail.

Philip Herlihy

4/10/2016 4:48:00 PM

0

In article <ned84i$c2i$1@gioia.aioe.org>, emfril@gmail.com says...
>
> If I add an alert at the end of the following function (from
> hmf.neocities.org/ix/is5.html):
>
> window.onload = function () {
> "use strict";
> document.getElementById("start").onclick = function () {
> requestFullScreen();
> init();
> alert("!"); // added alert
> };
> };
>
> I would expect that when the Start button is clicked first the
> requestFullScreen() would execute, then the init(), and when that one
> has finished executing, the alert would come up. But obviously my
> reasoning is wrong, because the alert appears immediately after the html
> is loaded.
>
> I would greatly appreciate an explanation of the flow of execution in
> JavaScript.
>
> Thanks,
>
> Eustace

I've noticed anomalies in execution flow in JavaScript. I can only
assume that browsers somehow "optimise" our code. Very odd...

--

Phil, London

Aleksandro

4/10/2016 6:20:00 PM

0

On 10/04/16 13:48, Philip Herlihy wrote:
> In article <ned84i$c2i$1@gioia.aioe.org>, emfril@gmail.com says...
>>
>> If I add an alert at the end of the following function (from
>> hmf.neocities.org/ix/is5.html):
>>
>> window.onload = function () {
>> "use strict";
>> document.getElementById("start").onclick = function () {
>> requestFullScreen();
>> init();
>> alert("!"); // added alert
>> };
>> };
>>
>> I would expect that when the Start button is clicked first the
>> requestFullScreen() would execute, then the init(), and when that one
>> has finished executing, the alert would come up. But obviously my
>> reasoning is wrong, because the alert appears immediately after the html
>> is loaded.
>>
>> I would greatly appreciate an explanation of the flow of execution in
>> JavaScript.
>>
>> Thanks,
>>
>> Eustace
>
> I've noticed anomalies in execution flow in JavaScript. I can only
> assume that browsers somehow "optimise" our code. Very odd...

Are you kidding, right? We all here know Javascript's line of execution
can diverge when a function is asynchronous.

Christoph M. Becker

4/11/2016 8:16:00 AM

0

On 10.04.2016 at 11:58, emf wrote:

> If I add an alert at the end of the following function (from
> hmf.neocities.org/ix/is5.html):
>
> window.onload = function () {
> "use strict";
> document.getElementById("start").onclick = function () {
> requestFullScreen();
> init();
> alert("!"); // added alert
> };
> };
>
> I would expect that when the Start button is clicked first the
> requestFullScreen() would execute, then the init(), and when that one
> has finished executing, the alert would come up. But obviously my
> reasoning is wrong, because the alert appears immediately after the html
> is loaded.

<https://developer.mozilla.org/de/docs/Web/API/Element/requestFull... says
(emphasis mine):

| The Element.requestFullscreen() method issues an *asynchronous*
| request to make the element be displayed full-screen.

The full specification of Element.requestFullScreen() clarifies the
details:
<https://fullscreen.spec.whatwg.org/#dom-element-requestfull....

--
Christoph M. Becker

Thomas 'PointedEars' Lahn

4/11/2016 10:35:00 PM

0

Christoph M. Becker wrote:

> On 10.04.2016 at 11:58, emf wrote:
>> window.onload = function () {
>> "use strict";
>> document.getElementById("start").onclick = function () {
>> requestFullScreen();
>> init();
>> alert("!"); // added alert
>> };
>> };
>>
>> [â?¦] But [â?¦] the alert appears immediately after the html is loaded.
>
> <https://developer.mozilla.org/de/docs/Web/API/Element/requestFull...
> says (emphasis mine):
>
> | The Element.requestFullscreen() method issues an *asynchronous*
> | request to make the element be displayed full-screen.
>
> The full specification of Element.requestFullScreen() clarifies the
> details:
> <https://fullscreen.spec.whatwg.org/#dom-element-requestfull....

I fail to see how your follow-up relates to the posting it is a follow-up
to.

--
PointedEars
FAQ: <http://PointedEars.... | SVN: <http://PointedEars.de...
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-...
Please do not cc me. / Bitte keine Kopien per E-Mail.

emf

4/12/2016 1:58:00 AM

0

On 2016-04-11 04:15, Christoph M. Becker wrote:
> On 10.04.2016 at 11:58, emf wrote:
>
>> If I add an alert at the end of the following function (from
>> hmf.neocities.org/ix/is5.html):
>>
>> window.onload = function () {
>> "use strict";
>> document.getElementById("start").onclick = function () {
>> requestFullScreen();
>> init();
>> alert("!"); // added alert
>> };
>> };
>>
>> I would expect that when the Start button is clicked first the
>> requestFullScreen() would execute, then the init(), and when that one
>> has finished executing, the alert would come up. But obviously my
>> reasoning is wrong, because the alert appears immediately after the html
>> is loaded.
>
> <https://developer.mozilla.org/de/docs/Web/API/Element/requestFull... says
> (emphasis mine):
>
> | The Element.requestFullscreen() method issues an *asynchronous*
> | request to make the element be displayed full-screen.
>
> The full specification of Element.requestFullScreen() clarifies the
> details:
> <https://fullscreen.spec.whatwg.org/#dom-element-requestfull....

I am relieved to hear that this anomaly in the flow of execution is just
that -- an anomaly, and that the requestFullscreen seems to be the
culprit. Well, since I need it, I have to just avoid its effects until I
find something better.

BTW, after working in Firefox and checking the code with JSlint, I've
started checking the exercises on Chrome and IE that I happen to have
here, and unfortunately I've found some issue there. First in Chrome,
for which I am mostly interested next, in exercise 4

http:/;emf.neocities.org/ix/ix4.html

when it gets in full screen the letters are not projected at the bottom
of the screen, unless you exit full screen mode. This happens only in
this exercise, and not in #5 that also projects letters, and also not in
Firefox. What's causing this?

Eustace

--
Eye exercises
http://emf.neocities.org/ix...

Osmo Saarikumpu

4/13/2016 3:56:00 AM

0

On 12/04/2016 04:57, emf wrote:
> BTW, after working in Firefox and checking the code with JSlint, I've
> started checking the exercises on Chrome and IE that I happen to have
> here, and unfortunately I've found some issue there. First in Chrome,
> for which I am mostly interested next, in exercise 4
>
> http:/;emf.neocities.org/ix/ix4.html

Should be:

http://emf.neocities.org/i...

See if correcting the markup error (stray end tag td) has an impact.

--
Best wishes, Osmo

emf

4/13/2016 8:42:00 AM

0

On 2016-04-12 23:55, Osmo Saarikumpu wrote:
> On 12/04/2016 04:57, emf wrote:
>> BTW, after working in Firefox and checking the code with JSlint, I've
>> started checking the exercises on Chrome and IE that I happen to have
>> here, and unfortunately I've found some issue there. First in Chrome,
>> for which I am mostly interested next, in exercise 4
>>
>> http:/;emf.neocities.org/ix/ix4.html
>
> Should be:
>
> http://emf.neocities.org/i...
>
> See if correcting the markup error (stray end tag td) has an impact.

Sorry, that was a typo. In Chrome, for some reason, in this exercise
the letters are shown not in the center, but lower, either I can see
only the top of the letter at the bottom, or the letter is below the
screen and can't be seen at all.

emf

--
Spherical Triangle Calculator
http://emf.neocities.org/tr/sphe...

emf

4/15/2016 4:23:00 AM

0

On 2016-04-13 04:41, emf wrote:
> On 2016-04-12 23:55, Osmo Saarikumpu wrote:
>> On 12/04/2016 04:57, emf wrote:
>>> BTW, after working in Firefox and checking the code with JSlint, I've
>>> started checking the exercises on Chrome and IE that I happen to have
>>> here, and unfortunately I've found some issue there. First in Chrome,
>>> for which I am mostly interested next, in exercise 4
>>>
>>> http:/;emf.neocities.org/ix/ix4.html
>>
>> Should be:
>>
>> http://emf.neocities.org/i...
>>
>> See if correcting the markup error (stray end tag td) has an impact.
>
> Sorry, that was a typo. In Chrome, for some reason, in this exercise
> the letters are shown not in the center, but lower, either I can see
> only the top of the letter at the bottom, or the letter is below the
> screen and can't be seen at all.
>
> emf

I am not sure what exactly the problem was, but after making minor -- I
think -- inaccuracies in the html, css, and js code, the webpage is now
running OK in both Firefox and Chrome from the website, but *not* from
the local file. If someone has any idea for why this is so, I'd
certainly like to know, however now this issue is rather academic.

Your silence in ths newsgroup is quite articulate!

Thanks,

Eustace

--
Eue Exercises
http://emf.neocities.org/ix...

Michael Haufe (\"TNO\")

4/15/2016 7:54:00 PM

0

On Thursday, April 14, 2016 at 11:22:42 PM UTC-5, emf wrote:

> I am not sure what exactly the problem was, but after making minor -- I
> think -- inaccuracies in the html, css, and js code, the webpage is now
> running OK in both Firefox and Chrome from the website, but *not* from
> the local file. If someone has any idea for why this is so, I'd
> certainly like to know, however now this issue is rather academic.
>
> Your silence in ths newsgroup is quite articulate!

XHR will no doubt fail these days on local filesystem due to security settings.

Your network inspector will probably even show you this error.

Set up a localhost site and run it from there.