开发者

Set focus to a Silverlight control from javascript

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜