/    Sign up×
Community /Pin to ProfileBookmark

Parsing / Displaying html before javascript

Hi!

Just learning javascript.

  • 1. I have a paragraph that says : “Hello”

  • 2. Then by javascript, I set an alert that says “stop”

  • 3. Then I change the paragraph content by javascript again.
  • My question is: Why does the initial “Hello” text is never seen?
    see the fiddle! :

    [url]https://jsfiddle.net/brsastre/gq1f8tch/[/url]

    to post a comment
    JavaScript

    17 Comments(s)

    Copy linkTweet thisAlerts:
    @rootJan 02.2017 — Because you are using JSFiddle

    if you used an editing system on your PC, you would get proper results and not something that tries to imitate what really happens.
    Copy linkTweet thisAlerts:
    @shakazorbaJan 02.2017 — Hi!

    Just learning javascript.

  • 1. I have a paragraph that says : "Hello"

  • 2. Then by javascript, I set an alert that says "stop"

  • 3. Then I change the paragraph content by javascript again.


  • My question is: Why does the initial "Hello" text is never seen?

    see the fiddle! :

    https://jsfiddle.net/brsastre/gq1f8tch/[/QUOTE]


    I first see Hello

    then I see an alert that says stop

    then I see Good Bye!
    Copy linkTweet thisAlerts:
    @rootJan 02.2017 — I first see Hello

    then I see an alert that says stop

    then I see Good Bye![/QUOTE]


    I don't, all I see is good bye then stop alert pop up.

    People insist on using these fiddles and code pens but don't stop to think that any problems arise from using these services when writing code can easily be done on their local machine with minimal tools and instant results and proper bug tracking.

    So in simple terms, write code on your PC not on-line.
    Copy linkTweet thisAlerts:
    @SempervivumJan 02.2017 — Don't work for me neither, in none of the common browser. Doesn't work in a local test page.

    Hallo shakazorba, how did you test this? Which browser did you use?
    Copy linkTweet thisAlerts:
    @rootJan 02.2017 — I tried it in a file on my PG using Chrome.

    I get Hello then a pop up, when acknowledged the pop up the element then changes to Good bye

    So it appears that the results are variable.
    Copy linkTweet thisAlerts:
    @shakazorbaJan 02.2017 — Don't work for me neither, in none of the common browser. Doesn't work in a local test page.

    Hallo shakazorba, how did you test this? Which browser did you use?[/QUOTE]


    I use (don't laugh)

    theEdge

    [canned-message]attachments-removed-during-migration[/canned-message]
    Copy linkTweet thisAlerts:
    @shakazorbaJan 02.2017 — Because the alert prevents

    further execution it must

    be dismissed before

    the contents of

    results can

    change

    [CODE]

    <body>
    <p id="results">Hello</p>
    <script>
    alert('stop');
    document.getElementById("results").innerHTML = "Good Bye!";
    </script>
    <body>

    [/CODE]
    Copy linkTweet thisAlerts:
    @rootJan 02.2017 — Yes it would normally but code tools like fiddle and codepen don't follow normal execution processes that a browser would follow.
    Copy linkTweet thisAlerts:
    @brsastreauthorJan 03.2017 — Nope, I tried this before on my Chrome. Then copied to Jsfiddle in order for you to actually see the execution. Thanks!
    Copy linkTweet thisAlerts:
    @brsastreauthorJan 03.2017 — Really? On Jsfiddle? What browser are you using? Thanks!
    Copy linkTweet thisAlerts:
    @brsastreauthorJan 03.2017 — Because you are using JSFiddle

    if you used an editing system on your PC, you would get proper results and not something that tries to imitate what really happens.[/QUOTE]


    Nope, I tried this before on my Chrome. Then copied to Jsfiddle in order for you to actually see the execution. Thanks!
    Copy linkTweet thisAlerts:
    @brsastreauthorJan 03.2017 — I don't, all I see is good bye then stop alert pop up.

    People insist on using these fiddles and code pens but don't stop to think that any problems arise from using these services when writing code can easily be done on their local machine with minimal tools and instant results and proper bug tracking.

    So in simple terms, write code on your PC not on-line.[/QUOTE]


    I tried this before on my local machine (Chrome) and got the same result. THEN copied to Jsfiddle in order for you to actually see the execution. Thanks!
    Copy linkTweet thisAlerts:
    @brsastreauthorJan 03.2017 — Don't work for me neither, in none of the common browser. Doesn't work in a local test page.

    Hallo shakazorba, how did you test this? Which browser did you use?[/QUOTE]


    What does "Hallo shakazorba" means?

    I test this on my local machine (Chrome). Then copied to Jsfiddle for you to actually see this issue. Got any clues? Are you advanced? Thanks!
    Copy linkTweet thisAlerts:
    @brsastreauthorJan 03.2017 — I tried it in a file on my PG using Chrome.

    I get Hello then a pop up, when acknowledged the pop up the element then changes to Good bye

    So it appears that the results are variable.[/QUOTE]


    I also tried on my local Chrome, and don't see the "Hello" at all.

    It seems it depends... but on what? That's what I am trying to figure out. Thanks!
    Copy linkTweet thisAlerts:
    @brsastreauthorJan 03.2017 — Because the alert prevents

    further execution it must

    be dismissed before

    the contents of

    results can

    change

    [CODE]

    <body>
    <p id="results">Hello</p>
    <script>
    alert('stop');
    document.getElementById("results").innerHTML = "Good Bye!";
    </script>
    <body>

    [/CODE]
    [/QUOTE]


    But the alert is AFTER "Hello". First "Hello" is parsed by the browser, THEN alert is triggered. So, why is it not visible? Thanks!
    Copy linkTweet thisAlerts:
    @brsastreauthorJan 03.2017 — Yes it would normally but code tools like fiddle and codepen don't follow normal execution processes that a browser would follow.[/QUOTE]

    I don't think JsFiddle is the problem. I tried this before on my local machina (Chrome). Then copied to Jsfiddle in order for you to actually see the execution. Thanks!
    Copy linkTweet thisAlerts:
    @rootJan 03.2017 — Well anything code wise is easier to post here than use those on-line tools, thats what the BBCode tags are for, make it easier to copy and if its too big, you post a thread and attach a text file.
    ×

    Success!

    Help @brsastre spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.2,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,
    )...