神剑山庄资源网 Design By www.hcban.com
复制代码 代码如下:
/*
描述: CHECKBOX控件
版本: 1.1
备注: CHECKBOX控件背后跟随的文字
是获取CHECKBOX对象的htc_myLabel来显示的
更新添加indeter属性,用来增加不确定的选择
*/
<public:component>
<public:attach event="oncontentready" onevent="fnInit()" />
<public:attach event="onpropertychange" onevent="fnPropertychange()" />
<script language="Javascript">
var checkBoxImg=window.document.createElement("IMG");
ImageArray=[];
ImageArray["checkbox_false"]="checkbox_false.gif";
ImageArray["checkbox_false_down"]="checkbox_false_down.gif";
ImageArray["checkbox_false_over"]="checkbox_false_over.gif";
ImageArray["checkbox_true"]="checkbox_true.gif";
ImageArray["checkbox_true_down"]="checkbox_true_down.gif";
ImageArray["checkbox_true_over"]="checkbox_true_over.gif";
ImageArray["checkbox_indeter"]="checkbox_indeter.gif";
ImageArray["checkbox_indeter_down"]="checkbox_indeter_down.gif";
ImageArray["checkbox_indeter_over"]="checkbox_indeter_over.gif";
function preLoad(path,obj){
for(i in obj){
this[i]=new Image();
this[i].src=path+obj[i];
}
return this;
}
preb=new preLoad("images/",ImageArray);
function fnInit(){
var o=element;
if(o.type=="checkbox"){
var _table=window.document.createElement("TABLE");
_table.cellSpacing="0px";
_table.cellPadding="0px";
_table.border="0px";
if(o.disabled){
_table.style.filter="alpha(Opacity=50)";
}
else{
_table.style.filter="";
}
_table.style.display="inline";
var _tr=_table.insertRow();
var _td=_tr.insertCell();
if (o.checked){
checkBoxImg.src=preb["checkbox_true"].src;
}
else{
checkBoxImg.src=preb["checkbox_false"].src;
}
if(o.indeter=="true"){
o.indeterminate="true";
checkBoxImg.src=preb["checkbox_indeter"].src;
}
_td.appendChild(checkBoxImg);
_td=_tr.insertCell();
_td.style.verticalAlign="bottom";
if(o.htc_myLabel){
_td.innerHTML=" <label style='cursor: hand'>"+o.htc_myLabel+"</label>";
}
o.insertAdjacentElement("afterEnd",_table);
o.style.display="none";
_table.attachEvent("onmouseover",function(){Baction("over")});
_table.attachEvent("onmouseout",function(){Baction("out")});
_table.attachEvent("onmousedown",function(){Baction("down")});
_table.attachEvent("onmouseup",function(){Baction("up")});
_table.attachEvent("onclick",function(){fnClick()});
}
}
function fnPropertychange(){
var o=element;
switch(event.propertyName.toString().toLowerCase()){
case "checked":
Baction("up");
break;
}
}
function fnClick(){
var o=element;
if(o.type=="checkbox"){
if(o.disabled)return;
if(o.checked){
checkBoxImg.src=preb["checkbox_false"].src;
}
else{
checkBoxImg.src=preb["checkbox_true"].src;
}
o.checked=!o.checked;
}
}
function Baction(action){
var o=element;
if(o.type=="checkbox"){
if(o.disabled)return;
if(action=="up"||action=="over"){
if(o.indeterminate){
checkBoxImg.src=preb["checkbox_indeter_over"].src;
}
else if(o.checked){
checkBoxImg.src=preb["checkbox_true_over"].src;
}
else{
checkBoxImg.src=preb["checkbox_false_over"].src;
}
}
if(action=="out"){
if(o.indeterminate){
checkBoxImg.src=preb["checkbox_indeter"].src;
}
else if(o.checked){
checkBoxImg.src=preb["checkbox_true"].src;
}
else{
checkBoxImg.src=preb["checkbox_false"].src;
}
}
if(action=="down"){
if(o.indeterminate){
checkBoxImg.src=preb["checkbox_indeter_down"].src;
}
else if(o.checked){
checkBoxImg.src=preb["checkbox_true_down"].src;
}
else{
checkBoxImg.src=preb["checkbox_false_down"].src;
}
o.indeterminate=false;
}
}
}
</script>
</public:component>
测试例子:
复制代码 代码如下:
<html>
<head>
<title> 新文档 </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="FlashSoft">
<meta name="Keywords" content="">
<meta name="Description" content="FlashSoft">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="Text/Css">
input.checkbox{
behavior:url("behaviors/checkbox.htc");cursor: hand;
}
</style>
</head>
<body>
<input name="chk1" type="checkbox" class="checkbox" htc_myLabel="音乐" checked>
<input name="chk1" type="checkbox" class="checkbox" htc_myLabel="体育" disabled>
<input name="chk1" type="checkbox" class="checkbox" htc_myLabel="新闻">
<input name="chk1" type="checkbox" class="checkbox" htc_myLabel="不确定属性1" indeter="true" checked>
<input name="chk1" type="checkbox" class="checkbox" htc_myLabel="不确定属性2" indeter="true" disabled>
<input name="chk1" type="checkbox" class="checkbox" htc_myLabel="不确定属性3" indeter="true">
</body>
</html>
下载此文件
/*
描述: CHECKBOX控件
版本: 1.1
备注: CHECKBOX控件背后跟随的文字
是获取CHECKBOX对象的htc_myLabel来显示的
更新添加indeter属性,用来增加不确定的选择
*/
<public:component>
<public:attach event="oncontentready" onevent="fnInit()" />
<public:attach event="onpropertychange" onevent="fnPropertychange()" />
<script language="Javascript">
var checkBoxImg=window.document.createElement("IMG");
ImageArray=[];
ImageArray["checkbox_false"]="checkbox_false.gif";
ImageArray["checkbox_false_down"]="checkbox_false_down.gif";
ImageArray["checkbox_false_over"]="checkbox_false_over.gif";
ImageArray["checkbox_true"]="checkbox_true.gif";
ImageArray["checkbox_true_down"]="checkbox_true_down.gif";
ImageArray["checkbox_true_over"]="checkbox_true_over.gif";
ImageArray["checkbox_indeter"]="checkbox_indeter.gif";
ImageArray["checkbox_indeter_down"]="checkbox_indeter_down.gif";
ImageArray["checkbox_indeter_over"]="checkbox_indeter_over.gif";
function preLoad(path,obj){
for(i in obj){
this[i]=new Image();
this[i].src=path+obj[i];
}
return this;
}
preb=new preLoad("images/",ImageArray);
function fnInit(){
var o=element;
if(o.type=="checkbox"){
var _table=window.document.createElement("TABLE");
_table.cellSpacing="0px";
_table.cellPadding="0px";
_table.border="0px";
if(o.disabled){
_table.style.filter="alpha(Opacity=50)";
}
else{
_table.style.filter="";
}
_table.style.display="inline";
var _tr=_table.insertRow();
var _td=_tr.insertCell();
if (o.checked){
checkBoxImg.src=preb["checkbox_true"].src;
}
else{
checkBoxImg.src=preb["checkbox_false"].src;
}
if(o.indeter=="true"){
o.indeterminate="true";
checkBoxImg.src=preb["checkbox_indeter"].src;
}
_td.appendChild(checkBoxImg);
_td=_tr.insertCell();
_td.style.verticalAlign="bottom";
if(o.htc_myLabel){
_td.innerHTML=" <label style='cursor: hand'>"+o.htc_myLabel+"</label>";
}
o.insertAdjacentElement("afterEnd",_table);
o.style.display="none";
_table.attachEvent("onmouseover",function(){Baction("over")});
_table.attachEvent("onmouseout",function(){Baction("out")});
_table.attachEvent("onmousedown",function(){Baction("down")});
_table.attachEvent("onmouseup",function(){Baction("up")});
_table.attachEvent("onclick",function(){fnClick()});
}
}
function fnPropertychange(){
var o=element;
switch(event.propertyName.toString().toLowerCase()){
case "checked":
Baction("up");
break;
}
}
function fnClick(){
var o=element;
if(o.type=="checkbox"){
if(o.disabled)return;
if(o.checked){
checkBoxImg.src=preb["checkbox_false"].src;
}
else{
checkBoxImg.src=preb["checkbox_true"].src;
}
o.checked=!o.checked;
}
}
function Baction(action){
var o=element;
if(o.type=="checkbox"){
if(o.disabled)return;
if(action=="up"||action=="over"){
if(o.indeterminate){
checkBoxImg.src=preb["checkbox_indeter_over"].src;
}
else if(o.checked){
checkBoxImg.src=preb["checkbox_true_over"].src;
}
else{
checkBoxImg.src=preb["checkbox_false_over"].src;
}
}
if(action=="out"){
if(o.indeterminate){
checkBoxImg.src=preb["checkbox_indeter"].src;
}
else if(o.checked){
checkBoxImg.src=preb["checkbox_true"].src;
}
else{
checkBoxImg.src=preb["checkbox_false"].src;
}
}
if(action=="down"){
if(o.indeterminate){
checkBoxImg.src=preb["checkbox_indeter_down"].src;
}
else if(o.checked){
checkBoxImg.src=preb["checkbox_true_down"].src;
}
else{
checkBoxImg.src=preb["checkbox_false_down"].src;
}
o.indeterminate=false;
}
}
}
</script>
</public:component>
测试例子:
复制代码 代码如下:
<html>
<head>
<title> 新文档 </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="FlashSoft">
<meta name="Keywords" content="">
<meta name="Description" content="FlashSoft">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="Text/Css">
input.checkbox{
behavior:url("behaviors/checkbox.htc");cursor: hand;
}
</style>
</head>
<body>
<input name="chk1" type="checkbox" class="checkbox" htc_myLabel="音乐" checked>
<input name="chk1" type="checkbox" class="checkbox" htc_myLabel="体育" disabled>
<input name="chk1" type="checkbox" class="checkbox" htc_myLabel="新闻">
<input name="chk1" type="checkbox" class="checkbox" htc_myLabel="不确定属性1" indeter="true" checked>
<input name="chk1" type="checkbox" class="checkbox" htc_myLabel="不确定属性2" indeter="true" disabled>
<input name="chk1" type="checkbox" class="checkbox" htc_myLabel="不确定属性3" indeter="true">
</body>
</html>
下载此文件
标签:
用htc实现CHECKBOX控件
神剑山庄资源网 Design By www.hcban.com
神剑山庄资源网
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
神剑山庄资源网 Design By www.hcban.com
暂无用htc实现CHECKBOX控件的评论...
更新日志
2024年09月30日
2024年09月30日
- 孙悦.1996-伙伴【正大国际】【WAV+CUE】
- 纪钧瀚《钢琴阅读时光 雨中书店聆听轻音乐》[FLAC/分轨][399.62MB]
- 证声音乐图书馆《走向自然 疗心爵士乐》[320K/MP3][87.4MB]
- 证声音乐图书馆《走向自然 疗心爵士乐》[FLAC/分轨][184.94MB]
- 陈慧娴.2018-Priscilla-Ism演唱会3CD(2024环球红馆40复刻系列)【环球】【WAV+CUE】
- 郑秀文.1999-我应该得到(国)【华纳】【WAV+CUE】
- 陈家慧.2011-钢琴酒吧2CD【龙吟唱片】【WAV+CUE】
- 证声音乐图书馆《雨季 蓝调吉他 Rainy Blues》[320K/MP3][45.01MB]
- 证声音乐图书馆《雨季 蓝调吉他 Rainy Blues》[FLAC/分轨][109.13MB]
- 赞多《序章》[320K/MP3][45.54MB]
- 许巍.2004-每一刻都是崭新的【步升大风】【WAV+CUE】
- 群星.2024-四方馆影视原声带【韶愔音乐】【FLAC分轨】
- 陈雷.1997-安锁咧【金圆唱片】【WAV+CUE】
- 关淑怡.2013-MY.FAVORITE.SK.3CD【环球】【WAV+CUE】
- Sweety.2006-花言乔语【丰华】【WAV+CUE】