6060 < a href ="#features "> Features</ a >
6161 < ul class ="nav ">
6262 < li > < a href ="#features-custom-schemes "> Custom Schemes</ a > </ li >
63+ < li > < a href ="#features-javascript-integration "> JavaScript Integration</ a > </ li >
6364 </ ul >
6465 </ li >
6566 < li > < a href ="#useful-links "> Useful Links</ a > </ li >
@@ -84,12 +85,10 @@ <h1 id="introduction">Introduction to CefSharp</h1>
8485 < strong > A framework</ strong > for embedding web-browsing-like capabilities to a standard .NET
8586 application (WPF or Windows Forms).
8687 </ li >
87-
8888 < li >
8989 < strong > A set of high-level custom controls</ strong > to make it reasonably easy to integrate
9090 these capabilities in your application.
9191 </ li >
92-
9392 < li >
9493 < strong >
9594 Built on top of < a href ="http://code.google.com/p/chromiumembedded/ "> CEF</ a > ,
@@ -98,12 +97,10 @@ <h1 id="introduction">Introduction to CefSharp</h1>
9897 </ ul >
9998 </ p >
10099 </ div >
101-
102100 < div class ="bs-docs-section ">
103101 < div class ="page-header ">
104102 < h1 id ="features "> Features</ h1 >
105103 </ div >
106-
107104 < h3 > State-of-the-art HTML5 and Javascript support</ h3 >
108105 < p >
109106 Perhaps very obvious, but still worth mentioning. Since CefSharp is based on
@@ -113,15 +110,13 @@ <h3>State-of-the-art HTML5 and Javascript support</h3>
113110 < a href ="http://html5test.com/compare/browser/chrome29.html "> 463 points out of 500</ a > on
114111 < a href ="http://www.html5test.com "> html5test.com</ a > .
115112 </ p >
116-
117113 < h3 > Support for both x86 and x64</ h3 >
118114 < p >
119115 Chromium 29 supports both x86 and x64, and so do we as of CefSharp 3.29.0. For the time being, it does not
120116 "auto-detect" the platform being used (since this is quite complex), so you have to choose either one for
121117 your project. This practically means that you will have to compile & package separate
122- binaries/installers of your app for x86 and x64 respectively.
118+ binaries/installers of your app for x86 and x64 respectively if you want/need to support both of them .
123119 </ p >
124-
125120 < h3 id ="features-custom-schemes "> Custom Schemes</ h3 >
126121 < p >
127122 Declare a factory class like this:
@@ -138,7 +133,6 @@ <h3 id="features-custom-schemes">Custom Schemes</h3>
138133 }
139134 }
140135 </ pre >
141-
142136 ...and the actual scheme handler class like this:
143137
144138 < pre data-shbrush ="csharp ">
@@ -162,7 +156,6 @@ <h3 id="features-custom-schemes">Custom Schemes</h3>
162156 }
163157 }
164158 </ pre >
165-
166159 Finally, you have to register this scheme handler using some code like this:
167160
168161 < pre data-shbrush ="csharp ">
@@ -180,11 +173,9 @@ <h3 id="features-custom-schemes">Custom Schemes</h3>
180173 Cef.Initialize(settings);
181174 }
182175 </ pre >
183-
184176 It's important that the scheme registration takes place before the < code > Cef.Initialize()</ code > gets
185177 called. (This is different to how things was being done in CefSharp version 1.)
186178 </ p >
187-
188179 < h4 > Asynchrony</ h4 >
189180 < p >
190181 CefSharp supports custom schemes using an
@@ -194,10 +185,43 @@ <h4>Asynchrony</h4>
194185 just signal using the < code > requestCompletedCallback()</ code > straight away, as in the example above.
195186 </ p >
196187
197- < h3 > Javascript integration</ h3 >
188+ < h3 id ="features-javascript-integration "> JavaScript integration</ h3 >
189+ < p >
190+ If you are reading this page in either one of the < strong > CefSharp.Wpf.Example</ strong > or
191+ < strong > CefSharp.WinForms.Example</ strong > sample applications, you can use the boxes on the right side
192+ of the screen to run arbitrary JavaScript code towards the context of this page. The C# code for performing
193+ these kinds of interactions are quite simple. Like this:
194+ </ p >
195+
196+ < pre data-shbrush ="csharp ">
197+ webBrowser.ExecuteScriptAsync(someScriptCode);
198+ </ pre >
199+
200+ < p >
201+ The code above will run the provided JavaScript snippet (which may do interesting things, like
202+ interrogating or modifying the DOM of the page, just to name one example out of many potential ones). The
203+ execution is of the "fire-and-forget" style; any result of the execution is silently disregarded. The
204+ execution is also < em > asynchronous</ em > in nature, a term which means that (among other things) the method
205+ may return before the actual code has actually been executed.
206+ </ p >
207+
208+ < p >
209+ This is the preferrably approach if possible, since it does not deadlock the UI in any way. However, we
210+ realize that it's not suitable for all scenarios. Have faith — there is a solution even for cases
211+ where you < em > do</ em > need to return a value. Just write your code like this:
212+ </ p >
213+
214+ < pre data-shbrush ="csharp ">
215+ var result = webBrowser.EvaluateScript("10 + 20");
216+ </ pre >
217+
218+ < p >
219+ Please note that only a limited number of data types are supported when returning the result above. Simple
220+ value types (int, float, etc) and strings all work, but do not expect to be able to return other JavaScript
221+ objects.
222+ </ p >
198223 < h3 > Hooks by which you can modify and/or override certain features of the web browsing</ h3 >
199224 </ div >
200-
201225 < div class ="bs-docs-section ">
202226 < div class ="page-header ">
203227 < h1 id ="useful-links ">
@@ -207,7 +231,6 @@ <h1 id="useful-links">
207231 < p >
208232 Here are a few pointers that might help you further explore the wonderful world of CefSharp:
209233 </ p >
210-
211234 < ul >
212235 < li > The < a href ="http://github.com/cefsharp/CefSharp "> GitHub project page</ a > </ li >
213236 < li >
0 commit comments