Set focus to a Silverlight control from javascript

≡放荡痞女 提交于 2019-12-22 08:57:44

问题


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

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


回答1:


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')



来源:https://stackoverflow.com/questions/4107460/set-focus-to-a-silverlight-control-from-javascript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!