Hello world command goes silent :-(

Hi from 6 degrees C getting dark York UK :smile:

Just started my first Javascript tutorial and Ive tripped at the first hurdle! My question is please my doesn’t the Hello word command show with the below basic code?

Hi from 6 degrees C getting dark York UK :smile:

Just started my first Javascript tutorial and Ive tripped at the first hurdle! My question is please my doesn’t the Hello word command show with the below basic code?

<html>
<head>
<script>
	alert("Hello, world!");
</script>
</head>
<body>
<h1>My first JS page</h1>
</body>
</html>

Thanks in advance,
David

What browser, because the alert does show for me…

Google Chrome v 48, just about to see if switching ad block off will make a difference!

Do you have alerts disabled? In your browser?

You should probably have head tags.

It does look odd not being in either a head or a body element, but it works for me (I’m running Chrome 48 myself)

I’m now googling why I cant see alerts in Chrome :frowning:

Have you ever seen an alert()? Have you looked into my advice?

It didn’t work for me as you had it but it did if moved the script to within the body.

I’m using a Chrome/Opera derivative

Ok now got it on a live link let the games begin -

It looks like you need to change the quotes in your Alert.

1 Like

Looks like you have an encoding problem. This is what I see when I view source…

1 Like

Yes ive spotted this, i put the code in Text edit Version 1.11 (325) perhaps this is note behaving as notepad?

Next step in learning JavaScript is to un-learn the alert() command that was replaced by console.log() for begugging several years ago (which is why some people now have alert turned off in their browser).

Success comrades from planet noob :slight_smile: http://test.davidclick.com/test/java-test.html

Off topic: I shamefully realised that I get a big confused when i set up css or JavaScript folders and need to point to them via the src= e.g.

Put another way does the / mean the code is one folder outside the file you are working with? and what would …/ mean. My lack of understanding in file structures means I mes about with / and …/ till something works. Any advise welcome

no preceeding dots or slashes or ./
points to (is relative to) the current directory.

../
points to the parent directory

/
points to the root directory of your web site on the server
or
the root directory of your hard drive on your computer.

1 Like

Nice one Ronpat, is this the topic of Linux folder structures?

  • / means start from the root of the site so if you put /css/test.css, then the it would look at example.com/css/test/css
  • …/ means to go up a level from your current file location
1 Like

Not sure what you’re asking. It’s the common way of noting directory structure whatever the O/S.

Ok cool thanks, just wanted a phrase to Google to watch a tutorial, I think i’m over thinking this, thank you for your help :slight_smile: