Back to my page

Developers

How to assign a JavaScript behavior to a tag?

It is tempting to use event handlers in the old way - that is, by putting the code directly on the tag's handler, like so:

<textarea onfocus="pieceOfCode(this);" >
  Default text
</textarea>

…it is no possible longer to do so in the UWA environment, where the pieceOfCode method above would need to be set globally, which can't be done.

It is therefore recommended to dynamically assign the behavior, through JavaScript:

widget.onLoad = function() {
  var textarea = widget.body.getElementsByTagName("textarea")[0];
  textarea.onfocus = function() { ... }
}

This has the added bonus of preventing the cluttering of the HTML code with JavaScript events…

Business

Click here if you want to know more about how netvibes can help you widgetize your brand and connect to your audience.

Developers

Click here to learn about netvibes open widget platform and you can create cool widgets for your service or your application that run everywhere.

Community

Click here to know how to join the netvibes community, get involved and help us translate and create a global directory of widgets for netvibes

Media

Click here to access informations about the company, our latest press release, our logos and media kit