Add link and Target attributes to the button with the HTC file

Source: Internet
Author: User
Tags add window
htc| button to do a Web application often need to use a button to jump to a page, or open a new window, because the button does not have the link property, so often write scripts to control, feel a bit of trouble, recently read some about HTC documents, found that HTC can add properties for the button, so write an example. File: test.htm <link href= "style.css" rel= "stylesheet" type= "Text/css" >
<input Type=button link= " http://www.sina.com.cn"value=" Open Sina >
<input Type=button link= " http://www.sina.com.cn"Value=" new window opens Sina "target=" _blank "> File: Style.css input{behavior:url (' input.htc ');}
Files: input.htc <public:component><!--Add Connection-->
<public:property name= "link" value= ""/><!--Add whether the property is open in a new window-->
<public:property name= "target" value= ""/>
<script language=javascript>
if (this.onclick==null)
{
Onclick=function ()
{
if (link!= "")
{
if (target== "_blank")
{
window.open (link);
}
Else
{
Location.href=link;
}
}
};
};
</script>
</public:component> to save the above code separately, put it in the same directory can be, as long as the introduction of STYLE.CSS, then the page button on more than two attributes link, target. If you set the button's OnClick property, the link property is not executed, after all, the default attribute takes precedence.

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.