微软新闻组的一个问题:当用户双击CRM界面上E-Mail,打开默认的邮件管理器(比如Outlook)来发送邮件。 其实只需要在窗体的OnLoad里写一个函数就可以达到这样的效果。
下面的代码也演示了怎样使用attachEvent函数来为CRM添加一个事件,同时演示了attachEvent函数的带参数调用方法(return function()),算是一个很好的例子。
<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->
/*
Double Click EmailAddress to Open in Outlook
*/
function CreateEmail(emailAddress)
{
return function ()
{
if (emailAddress != null && emailAddress.value.length > 0 )
{
window.navigate( " mailto: " + emailAddress.value);
}
}
}
crmForm.all.emailaddress1.attachEvent( ' ondblclick ' , CreateEmail(crmForm.all.emailaddress1));
crmForm.all.emailaddress2.attachEvent( ' ondblclick ' , CreateEmail(crmForm.all.emailaddress2));
crmForm.all.emailaddress3.attachEvent( ' ondblclick ' , CreateEmail(crmForm.all.emailaddress3));
function CreateEmail(emailAddress)
{
return function ()
{
if (emailAddress != null && emailAddress.value.length > 0 )
{
window.navigate( " mailto: " + emailAddress.value);
}
}
}
crmForm.all.emailaddress1.attachEvent( ' ondblclick ' , CreateEmail(crmForm.all.emailaddress1));
crmForm.all.emailaddress2.attachEvent( ' ondblclick ' , CreateEmail(crmForm.all.emailaddress2));
crmForm.all.emailaddress3.attachEvent( ' ondblclick ' , CreateEmail(crmForm.all.emailaddress3));