Following the book, Simply Javascript and the first example in chapter 2 to create an external Javascript page and link to an html doc - I don’t see anything in the page when I open it up in my browser.
I followed directions which were fairly simple. Not sure what I am doing wrong.
please help.
Thanks
are you looking at the page in the browser or in the view source page?
one more reason could be .js file. If the code is in the .js file and you are including that .js file in the page then you won’/t be able to see the java script code.
Okay, please provide the following information
[list=1][]What does your HTML code look like.
[]What does your script file look like.
[]What is the name of each file.
[]Where are the files individually located.[/list]
HTML: File name java.html
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”
“http://www.w3.org/TR/html4/strict.dtd”>
<html lang=“en-US”>
<head>
<title>The Running Man<title/>
<meta http-equiv=“Content-Type”
content=“text/html; charset=utf-8”>
<script type="text/javascript" src="java.js"></script>
</head>
</html>
JAVA:File name java.js
alert(“Arnie says hi!”);
Both files in a folder named practice.
Thank you for that. The code runs well when I run it locally.
Next up is relating to the file names themself. A known issue with Windows is that it commonly hides the extension of knows file types. This means that a file could be called “java.js.txt” but will only look to you on the screen as “java.js”
You can check if that’s the case by following these instructions:
Display your file extensions
I suggest you take a look at my code I have provided.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/javascript" href="http://www.example.com/example" title="program" />
<title>
Untitled Document
</title>
</head>
<body>
</body>
</html>
The files names are only java.js and java.html
What are you using to edit the files with?
Hahaha, sorry about that. I wrote that yesturday and I was up all night. Im mustve been seeing stars or something lol
<script language="text/javascript" src="example.js"></script>
What do you get when you adjust the address bar to be the script file
File Download window. I am asked if I want to open or save the file. When I open there is a window (windows script host) showing Error: object expected and other info.
(could it be I don’t see anything because my site is not hosted?)
I presume that you are using Internet Explorer.
In the tools menu do you see Developer Tools? It is in there that you can check what the browser is getting for the script, and start debugging things.
I will see what’s going on with Developer Tools but even if debugging is not advanced…it is for me so I may have more questions…
Thanks