Home Feed Sitemap

Onlineearnings Article directory

OnlineEarnings Article Board » Internet » Web-development » Enhance Your Web Pages With Dreamweaver's Javascript Behaviors
Welcome Guest

Enhance Your Web Pages With Dreamweaver's Javascript Behaviors

 Add2Netvouz
JavaScript is an easy-to-use programming language which runs client-side (on each web surfer's computer) and adds useful or decorative interactivity to web pages. No extra plug-ins need to be installed into the browser for JavaScript to run and, although it can be disabled by users to stop script running, it is safe to assume that any JavaScript code added to your pages will run on the vast majority of the computers of visitors to your site. Dreamweaver allows you to add JavaScript to your code automatically and easily by using "behaviors".

A behavior is simply a pre-written JavaScript function which can be triggered by a given event. To make the Behaviors window visible, choose Behaviors from the Window menu. Next select the element to which you want to attach the JavaScript. Finally, choose one of the available behaviors from the menu in Behaviors window. (The behaviors which are available will depend on the item you have highlighted.)

Dreamweaver attempts to guess the event that you would like to trigger the behavior such as an onMouseOver, onClick or OnDoubleClick. If it guesses the wrong event, simply choose the correct event from the drop-down menu next to the name of the event.

Dreamweaver has a wide selection of behaviors. However, they fall into four main categories: images, windows and alerts, forms and form fields and CSS. To see how behaviors work, let us look at some examples of some behaviors in each of those categories.

There was a time when almost every website featured the rollover effect on its navigation buttons. With the development of CSS, this is no longer the case. However, the facility of having an image change appearance when the mouse passes over it is still useful. Dreamweaver achieves this effect with the "Swap Image" behavior which can either be added to an image or can be created automatically by inserting a rollover image (Insert > Image Objects > Rollover Image) rather than a static one.

Dreamweaver's "Open Browser Window" behavior allows you to create the controversial JavaScript pop-ups. Due to its extensive misuse, many people have developed an extreme intolerance of this feature. However, there are situations where it is useful. For example, if a user is in the middle of filling out a form and clicks a help icon next to a certain item, a pop-up window is an ideal method of displaying the help topic.

In the form manipulation behaviors category, we have "Set Text of Text Field" and "Validate Form". The "Validate Form" behavior only applies to text fields and enables you to ensure, first of all, that a field has not been left blank; secondly, that a field contains a valid email address; thirdly, that a field contains a numeric value; and, fourthly, that a field contains a number within a given range.

An example of a behavior which manipulates CSS attributes is "Show/Hide Elements". This enables you to control the visibility of the content inside an HTML element, such as a DIV, heading or paragraph, based on user action. So, for example, when if you have a picture of a product, you can create DIVs with information on various aspects of the product and have the appropriate DIV content become visible as the user mouses over various parts of the product image.

Each behavior that you choose will create one or more JavaScript functions within the head area of your page. Part of the process of optimising your website (both in terms of accessibility and search engine compatibility) is to transfer this code to an external JavaScript file and then link the web page to the JavaScript file. To do this, you need to be in Code view and locate the function(s) generated by the behavior(s) you have used on your page. Cut all of the code between the opening and closing SCRIPT tags and place it in a text file which needs to be saved with a .js extension. Next, enter an src attribute inside the opening SCRIPT tag, for example
Slashdot   Slashdot It!

Comments

No comments posted.

Add Comment

You do not have permission to comment. If you log in, you may be able to comment.

latest articles from AndrewWhiteman

1: Microsoft Underdog As Expression Web Takes On Dreamweaver
2: Adobe Illustrator Blank Canvas Syndrome
3: Why Dreamweaver Has Become So Popular
4: Using Adobe Dreamweaver To Create A Basic Web Site
5: Common Errors Among QuarkXPresss Users
6: The Great New Features Offered By Adobe Dreamweaver CS3
7: Basic Errors Among Microsoft Word Users
8: Using Bookmarks To Make Your PDF Documents More Interactive

Top ten popular articles about Web Development

1: Royalty Free Music - Licensing & Copyright
2: Creating Your First HTML Form
3: Deciphering Website Design - Front End Development
4: Your First Online Form
5: Learn to Create a Web Form
6: Your First HTML Email Form
7: What Is Formmail And How Does It Work?
8: Developing a User Friendly Web
9: Your First Web Form
10: Microsoft Underdog As Expression Web Takes On Dreamweaver
Creative Commons License
This article is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 License.
ping