AdobeStock_455007340

Associating JavaScript with HTML Tags

Home » Associating JavaScript with HTML Tags

Client-side JavaScript is used to implement programmatic control of everything in a browser right within the browser itself. JavaScript code is usually invoked in response to something happening (a page is loaded, a screen element is clicked, the mouse moves over an image, a select list changes, etc). Associating JavaScript code with the appropriate HTML tags requires adding event attributes to those tags and referencing the required JavaScript code. ColdFusion Studio (and HomeSite) makes this task an easy one – simply switch to Tag Inspector mode (you can do this quickly by pressing F4), click on the appropriate tag in the editor window, click on the desired event from the Events list, select JavaScript or VBScript (both are supported) from the drop down list box to the right of the event, specify the handler name (or use the default), and then click OK. ColdFusion Studio will create a script function, add the event attribute to the tag, and associate the two – all you need then do is supply the JavaScript code itself. (Applies to: ColdFusion Studio 4 (or later))

Leave a Reply