Calling Javascript Code from a Button

Running Javascript code when a button is clicked is straightforward with Iron Speed Designer using the pass-through attribute mechanism on the button’s Properties dialog.

To access the Page Properties dialog, double-click the button control in the Design tab in Iron Speed Designer.  Then, go to the Attributes tab to add a new attribute with the appropriate name and value.

The easiest way to understand this mechanism is by example.

Display a message on the browser window status bar

This example displays a message in the browser window status bar as you mouse over a button.

Pass-Through Attribute

Value

Button-HtmlAttributes-onMouseMove

javascript:window.status='Press to Save Data...';

Button-HtmlAttributes-onMouseOut

javascript:window.status=' '

Display confirmation message for record deletion

You can display a confirmation dialog when the application user clicks a Delete button.

Pass-Through Attribute

Value

Button-HtmlAttributes-onClick

javascript:return confirm("Are you sure?");

Button-HtmlAttributes-onClientClick

OnClientClick is an alternative to OnClick

javascript:return confirm("Are you sure?");

Prompt when a button is clicked

This example displays a message in the browser window status bar as you mouse over a button a displays a confirmation dialog when the button is clicked.

Pass-Through Attribute

Value

Button-HtmlAttributes-onClick

javascript:return confirm("Are you sure?");

Button-HtmlAttributes-onMouseMove

javascript:window.status='Press to Close...';

Button-HtmlAttributes-onMouseOut

javascript:window.status=' '

Caveats

Ensure that JavaScript is enabled in your web browser.

See Also

Button Actions and Properties

Button Tag Pass-Through Attributes