1

I just started learning javascript about 30 minutes ago. I'm doing an online course and they gave me this code as an example. The person in the video did the exact same thing, but it only works for me when I do inline not external. My .js name is right and they're in the same folder.

The html:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>JavaScript Basics</title>    
  <script src=“cripts.js”></script>
 </head>
<body>
  <div class="container">
  <h1>Where to place your JavaScript code.</h1>
  </div>
</body>
</html>

and the js:

alert("YOU");

Nothing appears for me. I've tried everything to make it work, including different browsers. Could it be my computer or did I make a simple mistake?

5
  • 3
    So the name is supposed to be cripts.js? Commented Aug 29, 2016 at 0:41
  • 11
    Those are funny quote characters in the <sctipt tag line. I believe you copied it from somewhere, and as a beginner it would be helpful if you type manually instead. Commented Aug 29, 2016 at 0:42
  • scripts.js? (typo) Commented Aug 29, 2016 at 0:42
  • 3
    You have fancy quotes, those are not valid. Commented Aug 29, 2016 at 0:45
  • Copy and pasters conundrum... Commented Aug 29, 2016 at 0:48

2 Answers 2

2

It looks like your quotes are invalid :') Good beginner move! But it will be a simple fix. Note the should be ", this usually happens when copying and pasting code!

<script src="cripts.js"></script>

Also make sure your path and file name is correct?! cripts.js sounds like it is suppose to be scripts.js

Sign up to request clarification or add additional context in comments.

5 Comments

I rarely see this as a result of c&p, rather of using the wrong editor. Or: not using a code editor but a word processor.
Either way, they are invalid :D @Bergi - Maybe it's time for the OP to change editors :“)
It often happens in TextEdit on iOS.
Yeah, I wrote the command in my notes on pages on mac and then copied it. Can't believe I spent all that time for just that. Thank YOU.
Haha! It happens to the best of us @melkadri
0

A beginner mistake I made was to use <script>...</script> tags in the external javascript file. From HTML if you use:

<script type="text/javascript" src="../myApp/myFile.js"></script>

Then the external js file should just contain just the code such as:

function myFunction {} 

with no script tags. This is unlike linking to external css files which include the <style>...</style> tags.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.