Archive for September, 2007

1108 Part IV (Web hosting support) . JavaScript Core Language Reference

Wednesday, September 26th, 2007

1108 Part IV . JavaScript Core Language Reference Listing 41-4 (continued) function factorial(n) { if (n > 0) { return n * (factorial(n - 1)) } else { return 1 } }

Enter an input value:

Results:

This function is designed to be generalizable, accepting only the input value (n) as a parameter. In the form, the onClickevent handler of the button sends only the input value from one of the form s fields to the factorial() function. The returned value is assigned to the output field of the form. The factorial() function is totally ignorant about forms, fields, or buttons in this document. If I need this func tion in another script, I can copy and paste it into that script knowing that it has been pretested. Any generalizable function is part of my personal library of scripts from which I can borrow and saves me time in future scripting tasks. You cannot always generalize a function. Somewhere along the line in your scripts, you must have references to JavaScript or custom objects. But if you find that you re frequently writing functions that perform the same kind of actions, see how you can generalize the code and put the results in your library of ready-made functions. And if your audience uses browsers from Navigator 3 onward (and later versions of Internet Explorer 3 onward), consider placing these library functions in an external .jslibrary file. See Chapter 13 for details on this convenient way to share utility functions among many documents. Custom Objects In all the previous chapters of this book, you ve seen how conveniently the browser document object models organize all the information about the browser window and its document. What may not be obvious from the scripting you ve done so far is that JavaScript enables you to create your own objects in memory objects with properties and methods. These objects are not user-interface elements on the page but rather the kinds of objects that may contain data and script func tions (behaving as methods) whose results the user can see displayed in the browser window.
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

1107Chapter 41 .Functions and Custom Objects Recursion in

Tuesday, September 25th, 2007

Web server setup - 1103Chapter 41 .Functions and Custom Objects A JavaScript-enabled

Wednesday, September 19th, 2007

1102 Part IV . JavaScript Core Language Reference (Most popular web site)

Tuesday, September 18th, 2007

1101Chapter 41 .Functions and Custom (Shared web hosting) Objects function if

Tuesday, September 18th, 2007

1100 Part IV . JavaScript Core Language (Web hosting company) Reference

Monday, September 17th, 2007

1099Chapter 41 .Functions and Custom Objects function gretel(x,y,z) (Professional web hosting)

Monday, September 17th, 2007

1098 Part IV . JavaScript Core Language Reference (How to cite a web site)

Sunday, September 16th, 2007

1097Chapter 41 .Functions and Custom Objects At the (Web site traffic)

Sunday, September 16th, 2007

1096 Part IV . JavaScript Core Language Reference (Web hosting plans)

Sunday, September 16th, 2007