javascript: alert("Hi, I'm a program.");


Now hop over to and paste

alert("Hi, I'm a program.");

into the left hand window and press preview (the emulation runs the code) and you see the same result as previously.

Now make a copy of the html in the right window and save it to a html file on your own computer, use it as a template for testing, assignments and so on.

So how and where in your html template do you put the javascript? Like other things that go in Html pages Javascript has its own set of opening/closing tags and the code goes between them like this:

<script type="text/javascript"> alert("Hi, I'm a program."); </script>
and then very often (not always) the above is inserted between the head tags on the page. Try it now, paste the above anywhere between the head tags in a copy of your template and open it in your browser.

However the best way is to put the javascript code in its own file so make up a file with extension .js and put the code in there and store the file in the same folder as your template, then in your template file make a call to that file like this:

<script type="text/javascript" src="yourfile.js"> </script>
Now if you open the file in the browser, the code gets executed just as previously. This is the same way that third party libraries such as JQuery get called. ( Don't worry right now if you don't know what a library or JQuery is ). Notice that this is also what is happening in JS Bin, the code is being executed as if it were in a separate file.

The program consists of a statement which is a call to the function that is the value of the property named alert of the global object. If this doesn't make too much sense to you right now, all will become clear later on.

Next listen to Douglas Crockford's video at

Now do the javascript presentation and assignment at (those of you feeling a bit rusty on html or css should have a look at those presentations as well).

Start working your way through the List of Examples Online for sections 1.1 thru 2.5 . (Alternate link You should have some familiarity with all these lessons as soon as you possibly can.
[[--- Javascript, managed by the Mozilla Foundation, as of 27 July 2010 in version 1.8.5, is an implementation (dialect) of ECMA-262 Edition 5 (aka ECMAScript5) of 3 December 2009; support for this version exists in FF4, IE9, Safari5 and Chrome10. Older browsers would have support for Edition 3.

Although not strictly correct, most people when using the word "javascript" mean any implementation in browsers, not only that of Mozilla Foundation; in fact, Javascript is now an Oracle trademark.]]

Then put up a page on your site with answers to the following and any other thoughts you might have had up to now:-

When parsing a String into a number using the parseInt() method, we are advised to always provide the radix. Why is this?
Why do we lose precision when performing operations with decimal numbers in Javascript? Can you think of a few implications of why this would be a problem?
Do you understand why the next operation produces the given result 115 * 4 - 4 + 88 / 2 = 500?
What is a type, and why do you think types are useful in writing programs?
What does typeof(4.5); do, and why does typeof(typeof(4.5)); return "string" ?
"+" in Javascript is overloaded, what does this mean?
You might be interested in how your peers commented on this and other matters in the previous incarnation of this course, here Web development - twenty six concepts or technologies. Beginner best practices. Javascript Primitive Types Javascript Composite Types Another Intro


  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
©️2022 CSDN 皮肤主题:大白 设计师:CSDN官方博客 返回首页




¥2 ¥4 ¥6 ¥10 ¥20
余额支付 (余额:-- )



钱包余额 0