Web host music - 533Chapter 23 .The Form and Related Objects Tip

533Chapter 23 .The Form and Related Objects Tip a live connection with its object. To modify a property of the object that invokes an event handler function, you need to pass some object reference so that the function knows where to go to work on the object. Many programmers with experience in other languages expect parameters to be passed either by reference or by value, but not both ways. The rule of thumb in JavaScript, however, is fairly simple: object references are passed by reference; property values are passed by value. Here are some guidelines to follow when deciding what kind of value to pass to an event handler function: . Pass the entire form control object (this) when the function needs to make subsequent access to that same element (perhaps reading an object s value property, converting the value to all uppercase letters, and then writing the result back to the same object s value property). . Pass only one property (this.propertyName) when the function needs read- only access to that property. . Pass the entire FORM element object (this.form) for the function to access multiple elements inside a form (for example, a button click means that the function must retrieve a field s content). Also be aware that you can submit multiple parameters (for example, onClick= someFunction (this.form, this.name) ) or even an entirely different object from the same form (for example, onClick= someFunction (this.form.emailAddr.value) ). Simply adjust your function s incoming parameters accordingly. (See Chapter 41 for more details about custom functions.) E-mailing forms A common request among scripters is how to send a form via e-mail to the page s author. This includes the occasional desire to send secret e-mail to the author whenever someone visits the Web site. Let me address the privacy issue first. A site visitor s e-mail address is valuable personal information that you should not retrieve without the visitor s permission or knowledge. That s one reason why Netscape plugged a privacy hole in Navigator 2 that allowed submitting a form to a mailto: URL without requesting permission from the user. You can use some workarounds for this in Navigator 3, but I do not condone surreptitiously lifting e-mail addresses and therefore choose not to publicize those workarounds here. Besides, as more users gravitate to newer browser versions, the workarounds fail anyway. Microsoft, on the other hand, went too far in preventing forms e-mailing in the earliest browser versions. While Netscape s browsers reveal to the user in an alert that an e-mail message bearing the user s e-mail address (as stored in the browser s preferences) will be sent upon approval, Internet Explorer 3 does not send form content via e-mail at all. Internet Explorer 4 sends form content as an attachment through Microsoft Outlook, but only after displaying a mail composition window to the user. Starting with IE5, the process is much more fluid, but the action works best when Outlook is the default e-mail client on the computer. FORM
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.

Leave a Reply