behavior style property
Sets or retrieves the URL of a behavior file.
With the behavior property you can attach HTA or HTC files to style declarations.
These files are useful to create custom elements, with custom functionality.
For more information, visit the behavior (MSDN) page.
If you want to attach behaviors to an element dinamically, use the addBehavior method.
Element behaviors can also be specified for namespaces.
See the doImport method for details.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
CSS page for this property: behavior |
Possible values:
The type of this property is string.
Any of the following values (use the space character to separate them, each value can be used arbitrary times):
Where behaviorName specifies the name of an Internet Explorer default behavior. | |||||||
Where objID specifies the value of an object element's id property. | |||||||
Where URI specifies the location of the behavior file. |
Default: this property has no default value.
Example HTML code 1:
This example illustrates the use of the behavior property:
|
|||||
<head> <style> .example { behavior: url("hover.htc") } </style> </head> <body> <span class="example">Move the mouse over this text (element with behavior)</span><br /> <span>Move the mouse over this text (element without behavior)</span> </body> |
|||||
|
|||||
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates the use of the behavior property in JavaScript:
|
|||||
<head> <script type="text/javascript"> function GetBehavior () { var span = document.getElementById ("mySpan"); alert (mySpan.style.behavior); } </script> </head> <body> <span id="mySpan" style="behavior: url('hover.htc')"> Move the mouse over this text (element with behavior) </span> <br /> <button onclick="GetBehavior ();">Get behavior property</button> <br /> <span>Move the mouse over this text (element without behavior)</span> </body> |
|||||
|
|||||
Did you find this example helpful?
|
Supported by objects:
CSSStyleDeclaration, htmlElement.currentStyle, htmlElement.runtimeStyle, htmlElement.style
HTML elements:
a, abbr, acronym, address, applet, area, b, base, basefont, bdo, bgsound, big, blockquote, body, br, button, caption, center, cite, code, col, colgroup, comment, dd, del, dfn, dir, div, dl, dt, em, embed, fieldset, font, form, frame, frameset, h1, h2, h3, h4, h5, h6, head, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:hidden, input:image, input:password, input:radio, input:reset, input:submit, input:text, ins, isindex, kbd, label, legend, li, link, listing, map, marquee, menu, meta, nobr, noframes, noscript, object, ol, optgroup, option, p, param, pre, q, rt, ruby, s, samp, script, select, small, span, strike, strong, style, sub, sup, table, tbody, td, textarea, tfoot, th, thead, title, tr, tt, u, ul, var, wbr, xml, xmp
Related pages:
External links:
User Contributed Comments