开发者

Set focus to a Silverlight control from javascript

开发者 https://www.devze.com 2023-01-23 11:34 出处:网络
I\'m having a focus issue with Silverlight... 开发者_运维知识库 How can I set the focus to my Silverlight control using javascript?Add the following to your Silverlight hosting page (just above the o

I'm having a focus issue with Silverlight...

开发者_运维知识库

How can I set the focus to my Silverlight control using javascript?


Add the following to your Silverlight hosting page (just above the onSilverlightError function):

function appLoad(sender, args) {
    var xamlObject = document.getElementById('SilverlightObject');
    if (xamlObject != null)
        xamlObject.focus();
}

In the object declaration itself (e.g. in <object id='SilverlightObject') add this after <param name="onError" value="onSilverlightError" />:

    <param name="onLoad" value="appLoad" />

Also make sure the object names match (in this case 'SilverlightObject')

0

精彩评论

暂无评论...
验证码 换一张
取 消