views:

952

answers:

2

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  A: 

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.

ahin4114
It's not just HTMl, it's HTML and JavaScript. And probably CSS too.
Anthony
Still, it's just some Page in a IE Browser. Nothing more nothing fancy. jQuery will work just fine.
Tigraine
Fair comment Anthony, but any Javascript or CSS is going to be enclosed in a script or style tag, and therefore it is the data for that tag. We're talking about a web browser which parses XHTML markup, the exact nature of those tags is not relevant to the OP's question.
ahin4114
A: 

Is there any framework, similar to jquery, that can be used on the desktop?

TechGeek