0

hi want to learn javascript and i'm using ubuntu 9.04.i have google chrome and fire fox with enabled javascript.
All things are good but when i write a js file and open it in browser but nothing happening
html code loads but js not any hint why .

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by usiyalla
0

You can not open a .js file in your browser. You need to link it to a HTML file by using:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>My first page with JavaScript</title>
<script type='text/javascript' src='scripts/MyScript.js'></script>
</head>
<body>
</body>
</html>

Or write the code into the HTML file:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>My first page with JavaScript</title>
<script type='text/javascript'>
alert("This is some JavaScript code!");
</script>
</head>
<body>
</body>
</html>

~G

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.