Enhance Your Web Pages With Dreamweaver's Javascript Behaviors
by: AndrewWhiteman |
Total views: 232 |
Word Count: 645 |
View PDF | Print View
Share This Article
JavaScript is a simple, client-side scripting language which enables you to add exciting and interesting functionality to your HTML pages. It is built in to most web browsers and, although it can be deactivated, most people will have it enabled within their browser. JavaScript's uses includes the validation of entries within an HTML form and the detection of browser versions and presence or absence of plug-ins. Dreamweaver's implementation of JavaScript centres on the use of what it calls "behaviors".
A Dreamweaver behavior is an automatically generated JavaScript function which is activated by a given user or browser action. To use behaviors, choose Window > Behaviors. Before attaching a behavior, you must highlight one of the elements on your page such as a hyperlink or image. Then you need to choose a behavior by clicking on the plus sign in the top left of the Behaviors window.
You will also need to ensure that the correct event (click, double-click etc.) is linked to the behavior. Dreamweaver will always assign an event automatically. However, if this event is not the one you actually want, just select a different event by clicking on the drop-down menu located to the right of the name of the event in the Behaviors panel.
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.
In the alerts and windows category, we have Dreamweaver's "Open Browser Window" behavior. This creates the ever-popular pop-up window. When you assign the behavior, Dreamweaver asks you to choose the HTML page you would like displayed in the window as well as the attributes you would like to add or suppress, such as scroll bars or the ability to resize the window.
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.
Dreamweaver has a number of behaviors which can be applied manipulate the CSS attributes associated with a given page element. One such behavior is Show/Hide Elements. This enables you to make the content of an HTML element visible or hidden based on an action performed by the user. You can apply this behavior to the content of an H1, DIV, P(aragraph) basically, any element that can contain stuff.
Naturally, there is some overhead involved in using Dreamweaver's behavior in terms of the code generated within your web page. To make your pages accessible and search engine friendly, it is recommended that you transfer JavaScript code into an external .js file and then link each of your web pages to the external JavaScript file. In Dreamweaver's code view, highlight all of the JavaScript code between the opening and closing SCRIPT tags, then choose Cut from the Edit menu. Create an empty text file, paste in all the code and save the file with a .js file extension. Finally, in the opening SCRIPT tag on your web page type src="myscript.js", replacing "myscript" with the name of your file.
Share This Article
Rating: Not yet rated Next Article - The Easy Way To Make Sure You Are Using The Best Anti-spyware and Previous Article - Management Software To Drive Your Bottom Line
About the Author
The author is a trainer and developer with Macresource Computer Solutions, a UK IT training company offering Adobe Dreamweaver Classes in London and throughout the UK.
Comments
No comments posted.Add Comment
Popular Articles about: Software
1: Viagra2: Adobe Illustrator: Getting Past The Blank Canvas
3: How to use a poker software
4: MyCafeCup.com launched new AIO Internet Cafe Software + WiFi HotSpot Gateway Billing.
5: The Easy Way To Write An E-book
6: How to convert swf to Avi, iPod, iPhone, PSP, Zune
7: Optimize Your PC With Registry Cleaner
8: A new version of contextual German-English and English-German dictionary TranslateIt! for Windows
9: Pre-packaged vs. Custom Software
10: Getting Rid Of The This Nasty Philippine Made Virus
11: DOCUMENT SCANNING STORAGE of RECORDS DIGITIZING ARCHIVING PAPERLESS OFFICE NYC.
12: Using Personal Computers to Solve Humanitarian Problems
13: Find Home Renovation Software
14: Your Reaction to the Idea of Paying Students
15: The Story of Finding Longitude: It Was All a Question of Timing
16: Choosing the Turnkey Software for your Business
17: Tokenless Two Factor Authentication Ensures Secure Remote Access
18: The Way People Communicate Has Changed Over Time
19: Windows Vista Ultimate OEM Software
20: How To Safely Clean Windows Registry
21: Commercial Driver’s License CDL Manual
22: Does iBuzzPro Automatic Recruiter Software Actually Work?
23: How To Use Article Marketing For Free Unlimited Traffic
24: Big Ticket to Wealth Retail Store-- Is It Worth A Visit?
25: Management Software To Drive Your Bottom Line
26: Multiple Streams of Income...Surefire Way to Success
27: How to find an email address easily
28: Don't Buy a Myspace Friend Adder: Compare Consumer Ratings First
29: Cleaning Your Windows Registry Effectively
30: The Easy Way To Make Sure You Are Using The Best Anti-spyware