2

I am getting a random error when I attempt to link a javascript file to my web page. It has been a while since I have done any web development. However, I have checked old code and the methods are identical. I am attempting to use jquery for the first time and am not sure if that is effecting the results.

Here is the HTML header:

<!DOCTYPE html >
<html>
<head>
<link rel="stylesheet" href="Styles/layoutStyles.css" type="text/css">

<meta content="text/html; charset=UTF-8">

<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js”></script> 
<script src=”CommonMethods.js” type="text/javascript"></script>

<title>Insert title here</title>
</head> 

The "CommonMethods.js" file is the file I am attempting to use. It was initially in a lower directory then the HTML file. However, I moved it to the same directory for testing purposes.

This is the error I get:

GET file:///D:/Users/Thomas.Thomas-TOWER/Dropbox/Workspaces/Eclipse_Web_Develop…nder/WebContent/%C3%A2%E2%82%AC%C2%9DCommonMethods.js%C3%A2%E2%82%AC%C2%9D net::ERR_FILE_NOT_FOUND 

I am not sure where the %C3%A2%...ect. symbols came from. I am almost wondering if there is something wrong with the way I defined the charset.

Any suggestions?

I should also mention I am using Eclipse for this project.

4
  • 3
    You're using weird quotation marks around your scripts i.e. instead of " or '. Making your source code consistent may help. Commented Jun 6, 2014 at 1:37
  • Try using a real editor that doesn't butcher what you type... Notepad or Word are not good options for editing code. Commented Jun 6, 2014 at 1:46
  • 1
    @jahroy A thought before you spout out condescending judgments about using a "real editor": some blogs like WordPress turn quotes into smart quotes, even in code blocks. Perhaps Nehringtb copied and pasted the code from a blog and didn't notice the smart quotes? Commented Jun 6, 2014 at 3:19
  • @ChrisPeters - You're right, and it looks like he's probably using Eclipse. I still enjoyed making my condescending, immature comment. It would be nice if mighty Eclipse could be smart enough to detect and warn about trashy Microsoft quotes... Commented Jun 6, 2014 at 3:50

2 Answers 2

4

You're using smart quotes. Open the file in a real IDE (Netbeans, Eclipse, ShiftEdit, Coda, etc.) and replace them.

Also it's generally good practice to "root" script/style urls. (I.E. "/CommonMethods.js")

On any larger project relative urls can be problematic as you're not always at the root.

Another tip would be protocol-less URLs for 3rd party scripts (I.E. //ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js)

All modern browsers support this and it saves you headache from insecure content being run on a secure page

Also as of HTML5 type="text/javascript" is not longer required on script tags.

Also if you are using Visual Studio, Please remember to set Copy to Output Directory to Either Copy Always or Copy if Newer.

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

Comments

4

Your quote marks are fancy microsoft word quotes. Replace them with regular quotes and it should work. You should be able to visually see it above on the src of both scripts and the type of the first.

As a general rule, keep Microsoft Office away from your sourcecode files.

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.