Silverlight HTML-JS-DOM Bridge:现实世界的用例?

发布于 2024-09-15 01:51:43 字数 145 浏览 11 评论 0原文

我在网上看到了很多内容,这些内容展示了如何使用 Silverlight 来增强网页的概念验证教程,方法是通过将任务交给它来利用线程、操作 DOM、实现类似 Comet 的功能等

。看起来很有趣,但是,有没有人有任何现实世界的用例可以分享,因为我似乎找不到很多。

I've seen a lot of stuff online that shows proof of concept tutorials of how Silverlight can be used to enhance web pages by handing tasks off to it to make use of threading, manipulate the DOM, achieve Comet-like functionality etc.

It all seems very interesting, however, has any one got any real world use cases to share as I can't seem to find many.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泪痕残 2024-09-22 01:51:44

当然。我使用 HTML DOM 交互有几个原因。

首先,将现有 ASP.NET 应用程序迁移到 Silverlight 时。在我们使用的架构中,应用程序很大程度上基于 AJAX,并具有大量回调。我们无需为 Silverlight 重新发明轮子,而是能够使用 DOM 交互来提供桥梁,以便 Silverlight 控件可以以类似的方式回调。这意味着使用 ASP.NET 安全性和视图状态信息从服务器获取信息并将其拉入 Silverlight 应用程序。我们已经以 JSON 格式返回数据,因此可以直接解析回 Silverlight 应用程序。

另一个例子是与第三方控件和服务的交互。例如,Google Analytics 提供丰富的页面跟踪功能。该项目提供了一个很好的示例:

http://silverlightanalytics.codeplex.com/

应用程序可以在其中集成和即使您在 Silverlight 中运行,您本质上还是在跟踪点击、操作和页面视图。

我使用此功能的另一个地方是当 Silverlight 不用作应用程序,而是更多地用作页面上的一部分或控件时。虽然 Silverlight 控件可以使用本地通信相互通信,但这不适用于其他非 Silverlight 控件。通过使用 HTML-DOM 桥,您可以轻松地在组件之间构建基于 JavaScript 的通信。例如,Silverlight 控件可能是一个交互式世界地图,允许您浏览某个区域。当您选择区域时,它会引发一个 JavaScript 事件,其他控件会监听该事件并根据该原因进行更新。

您还可以将 Silverlight 用作类似于 Captcha 控件的控件,其中您的表单使用 DOM 桥来验证 Silverlight 应用程序中的用户输入。

我见过标签云应用程序,其中 Silverlight 控件使用 DOM 交互来遍历当前页面,然后基于此生成动画标签云。

希望这些能提供一些现实世界的例子。

Sure. I have used the HTML DOM interaction for several reasons.

First, when migration an existing ASP.NET application to Silverlight. In the architecture we worked with, the application was very heavily AJAX-based with plenty of callbacks. Instead of reinventing the wheel for Silverlight, we were able to use the DOM interaction to provide a bridge so the Silverlight control could callback in a similar fashion. This meant using the ASP.NET security and viewstate information to fetch information from the server and pull into the Silverlight application. We were already returning data in a JSON format so it was straightforward to parse back into the Silverlight application.

Another example is interaction with third-party controls and services. For example, Google Analytics provides rich page tracking features. This project provides a prime example:

http://silverlightanalytics.codeplex.com/

Where the application can integrate and even though you are running in Silverlight, you are essentially tracking clicks, actions, and page views.

Another place I've used this is when Silverlight isn't used as an application, but instead more of a part or a control on the page. While Silverlight controls can communicate with each other using the local communication, this doesn't work with other non-Silverlight controls. By using the HTML-DOM bridge you can easily build JavaScript-based communicatin between the components. Maybe the Silverlight control, for example, is an interactive world map that allows you to browse to a region. When you select the region, it raises a JavaScript event that the other controls listen to and update based on that reason.

You can also use Silverlight as a control like a Captcha control where your form uses the DOM bridge to validate user input into the Silverlight application.

I've seen tag cloud applications where the Silverlight control uses the DOM interaction to walk the current page and then generate an animated cloud of tags based on this.

Hopefully those provide some real world examples.

撩动你心 2024-09-22 01:51:44

我使用 DOM-Bridge 的一件事是引发事件。托管我的应用程序的 html 页面订阅这些事件并做出相应的反应。

例如,我的应用程序接收并显示来自 WCF Web 服务的销售数据。当数据更改时,会引发一个事件,以便页面的其余部分可以显示其他内容。

如果您无法使用 ASP.Net,则在 Silverlight 中向 Web 服务询问和接收数据比在 Javascript 中更容易且更不容易出错(而且速度更快,因为您可以使用优化的“binary-xml”编码器)。

我认为当您分发要嵌入到任意网站中的 silverlight 应用程序时,DOM 桥最有用,在这些网站中您无法对后端环境做出假设,但需要提供与 SL 应用程序交互的能力。

One thing I've used the DOM-Bridge for is to raise events. The html pages that host my application subscribe to these events and react consequently.

For example, my application receives and displays sales data coming from a WCF webservice. When the data changes, an event is raised so that the rest of the page can display other things.

If you can't use ASP.Net, asking and receiving data from a webservice is much easier and less error-prone in Silverlight than in Javascript (and is also faster because you can use the optimized "binary-xml" encoder).

I think the DOM bridge is most useful when you distribute a silverlight app to be embedded in arbitrary websites where you can't make assumptions on the backend environment but need to provide ability to interact with the SL app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文