Learn to use behavior in CSS

Source: Internet
Author: User
Tags object

We are accustomed to using cookies when we encounter refreshes to preserve the contents of the form, but it is very troublesome to do so, and the behavior in CSS is a good solution to the problem.

Like what:

The top one is the behavior function that is often used, and there are many other functions.

The grammar of Behavior is

Grammar:

Behavior:url (URL) | URL (#objID) | URL (#default #behaviorname)

Take value:

URL (URL): Specifies the DHTML behavior component (. htc) using an absolute or relative URL address.

URL (#objID): The behavior of using binary implementations (as ActiveX® controls). The #objID here is the id attribute value of the object

URL (#default #behaviorname): The default behavior of IE. specified by the name Identification (#behaviorName) of the behavior

Description: Sets or retrieves the DHTML behavior of an object. Multiple behaviors are separated by spaces.

When multiple behaviors attached to the same element conflict, the result is determined by the order in which the behavior is applied to the elements. The precedence of the latter behavior is higher than the previous behavior. For example, if multiple behaviors are used to set the object color, the result will be determined by the last action applied to the element. The same rule applies to the name conflicts that occur for properties, events, and methods that are provided by different behaviors.

You can use the Addbehavior method to dynamically attach behavior to an object.

This property is read-only for Currentstyle objects. is writable for other objects.

It is important to note that using the Behavior property of the style sheet (CSS) to inline definitions or to use the Addbehavior method to attach the behavior is automatically detached when the object is removed from the document tree. The behavior defined by a style sheet rule in a document is automatically detached when the object is removed from the document tree.

The corresponding script attribute is behavior. Example: P {behavior:url (#default #download);}

div {behavior:url (fly.htc) URL (shy.htc);}

div {behavior:url (#myObject);}

Application 1: Refresh also retains the text in the input box

. shistory {}{behavior:url (#default #savehistory);}

Application 2: Calling the script






把鼠标放在这里



Behave.htc


handler="hig_lite" />
handler="low_lite" />



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.