转自JIM Wang:把 isv.config.xml 按钮事件移动到 entity.onload()

大家都知道在ISV.CONFIG里可以添加按钮,然后添加按钮事件,比如下面:

< Entities >
  
< Entity name = " account " >
    
< ToolBar ValidForCreate = " 0 "  ValidForUpdate = " 1 " >
      
< Button Icon = " /_imgs/ico_18_debug.gif "  PassParams = " 1 "  WinParams = ""  WinMode = " 0 "  Client = " Web "  JavaScript = " alert('Hello World!'); " >
      
< Titles >
        
< Title LCID = " 1033 "  Text = " A button "   / >
       < / Titles>
       < ToolTips >
        
< ToolTip LCID = " 1033 "  Text = " A button "   / >
       < / ToolTips>
     < / Button>
     < ToolBarSpacer  / >
     < / ToolBar>
   < / Entity>
<!--  End Custom Entities  -->
< / Entities>

 

有的时候基于维护和其他一些考虑,可以将这个按钮事件放到entity的onload()事件里(比如你有大量的JavaScript代码)。但是可能你已经注意到了,这种isv.config生成的按钮 ID 是变化的,也就是说在onload()事件里,你无法通过 document.getElementById() 方法获取这个按钮,而isv.config.xml 文件本身又不支持ID设定,所以要用到不同的方法:

for  ( var  index  in  document.getElementsByTagName( " LI " )) 
{
    
if (document.getElementsByTagName( " LI " )[index].title  ==   " A button " )
    {
        document.getElementsByTagName(
" LI " )[index].onclick  =  Button_Click;
        
break ;
    }
}

function  Button_Click()
{
    alert(
" Hello World! " );
}

 

由于按钮是附属在节点"LI"上面,所以可以先遍历找到节点 "LI",然后确定哪个节点的Title=“A button”,就是在isv.config 里 指定的 Title。就可以实现这种功能了。

转载于:https://www.cnblogs.com/yanluckly/archive/2008/11/18/1335774.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值