Using jQuery in WinForms desktop app?

别说谁变了你拦得住时间么 提交于 2019-12-06 08:50:59

问题


We have a WinForms desktop application that uses the .NET 2.0 framework WebBrowser control quite extensively for displaying HTML. The HTML may be simple, or quite complicated. It may reside on disk, or it may be written directly to the document property at runtime.

I was wondering if anyone had any experience with using jQuery as a library for such desktop applications. Can i just reference the jquery.js file on disk, and use it just as if it were a web app? Are there any pitfalls that I need to be aware of?


回答1:


At the end of the day, it's just HTML markup in a browser, treat it as you would if you were working with a page to be viewed in any web browser. jQuery will work just fine assuming you can reference the library from the markup. This would require injecting a script reference into the markup at runtime.

You say that the source may reside on disk or be dynamically generated, I would introduce a pre-loaded step which either loads the file from disk, or generates the markup in memory, then (using string or XML manipulation), inject the jQuery reference and any associated scripts into the markup before populating the WebBrowser document. From there, just let the WebBrowser control do its job.



来源:https://stackoverflow.com/questions/352159/using-jquery-in-winforms-desktop-app

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