从 JavaScript 按钮调用 WPF 应用程序函数
我有一个 xbap 应用程序,我想要一个 javascript 按钮来调用该应用程序中的函数。 我在互联网上读过一些内容,似乎我必须使用网络控件(正确吗?)或对象控件来传递 id 或其他东西。我到底应该怎么做呢?一个小的 Vb.Net 例子会很有用。
假设我有这个类:
Class Page1
Public Sub Callback()
MsgBox("Something")
End Sub
End Class
并且我有一个带有 iframe 的 html 文件,如下所示:
<html>
</head>
<script>
function something() {
var ctrl = document.getElementById("testControl");
ctrl.Callback();
}
</script>
</head>
<body>
<object id="testControl" name="testControl" classid="clsid: ..." width="0" height="0"></object>
<input type="button" value="Change Size" onclick="something()" />
<br/>
<script>
document.write('<iframe id="frame1" name="frame1" width="200" height="197" src="http:// .... .xbap?id=' + 1 + '" frameborder="1" border="1" style="border: 1px solid #000000;" />');
</script>
</body>
</html>
我应该如何配置我的 vb.net 类和 html 文件以使其正常工作?谢谢。
I have a xbap application and i would like a javascript button to call a function from this application.
I've read something on Internet and it seems i have to use either a webcontrol (is that correct?) or an object control whom to pass an id or something. How should i do that exactly? A small Vb.Net example would be useful.
Let's assume i have this class:
Class Page1
Public Sub Callback()
MsgBox("Something")
End Sub
End Class
And i have a html file with an iframe that looks like this:
<html>
</head>
<script>
function something() {
var ctrl = document.getElementById("testControl");
ctrl.Callback();
}
</script>
</head>
<body>
<object id="testControl" name="testControl" classid="clsid: ..." width="0" height="0"></object>
<input type="button" value="Change Size" onclick="something()" />
<br/>
<script>
document.write('<iframe id="frame1" name="frame1" width="200" height="197" src="http:// .... .xbap?id=' + 1 + '" frameborder="1" border="1" style="border: 1px solid #000000;" />');
</script>
</body>
</html>
How should i configure my vb.net class and html file so that it works? thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这个问题似乎没有答案,并且很可能与其他问题有些重复。
但无论如何,我创建了一篇博客文章,其中有一个从 xbap 调用函数的 javascript 按钮。该解决方案适用于最新的浏览器。
检查一下:
http://hotzblog.com/ xbap-and-javascript-with-ie9-or-newer-solution-for-missingmethodception-problems/
This question seems to be unanswered, and is most likely bit duplicate with other questions out there.
But any how, I have created a blog post where there is a javascript button that calls function from xbap. This solution works with latest browsers out there.
Check it out at:
http://hotzblog.com/xbap-and-javascript-with-ie9-or-newer-solution-for-missingmethodexception-problems/