Javascript Alert

Hi Guys,

I´m completly stucked here. I wrote everything like Ivan did in his video but my browser just shows the line “node alert(“hello”);” and is not executing it in a new window. The word “alert” is also not turning blue in Atom like in Ivans Video. I googled it for like 3h now but still cant find anything.

1 Like

Hi I´m not sure what step in the course you are, but I can help how to show an alert i the browser.

alert("This is how we create an alert");

or you can also use prompt() to receive user input.

prompt("This is how we ask for user input");

I would remove the word node in your code and try to run it again.

Good luck… Tell me if you need more help with this. :slightly_smiling_face:

Ivo

1 Like

Hi Ivo,

Thank you for your help :slight_smile:

i dont have a “node” in the code :smile_cat: le:

This is what i wrote:

>  <html>
>   <head>
>     <title>THIS IS A GREAT WEBSITE</title>
>       <skript>
>           alert("hello");
>       </skript>
>   </head>
>   <body>
>       <h1>This is a title</h1>
>   </body>
> </html>

Greetings

Andy

Hi.
Script is written with ‘c’, not ‘k’.
:slightly_smiling_face:

Ivo

1 Like

You can also try to put the script inside the body tags instead of inn the heading. See what happens… :slightly_smiling_face:

<body>
  <script>
       alert("hello");
 </script>
</body>

Good luck.

Ivo

1 Like

OMG :dizzy_face:

In german its written with a “k”.

Thanks a lot for this

1 Like

No problem…
I know how you feel buddy. Been there, done that. I`m still doing it. :triumph:

Keep on grinding. And don’t be afraid to ask questions. That`s what we are here for.
Good luck. :+1:

Ivo

1 Like

Extra information:

The tag is used for meta information (other information that will most of the time not be displayed). It can be some information that will be used by search engines, the title of the page, the language of the page, …

The tag can be place in the , our outside those two.

  • Putting in the : the script might be executed while the is not accessible yet since it might still be loading the document.
  • Putting in the : the script will be executed and the tag is accessible (since you are inside of it). But the script might take a bit of time since the browser will wait the initialization of the body to be done.
  • Putting it outside (after the body tag, for instance): it is the best place to put your script. The document will be entirely loaded. And you will avoid the document loading process to be blocked by a script (depending of where you put your tag).
2 Likes

Hi everyone , can someone show me what i am doing wrong, i cannot get the alert function to work. This is how i wrote the script, when i type (a) in the space between the script functions the alert tab does not appear

Edit @Ivga80:

<script>
    alert("This is an alert!");
</script>

Good luck! :wink:
Ivo