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')
精彩评论