From 4c958cdfcb0f19676e76177ea5bf54074621a137 Mon Sep 17 00:00:00 2001
From: Per Lundberg
If you are reading this page in either one of the CefSharp.Wpf.Example or
CefSharp.WinForms.Example sample applications, you can use the boxes on the right side
- of the screen to run arbitrary JavaScript code towards the context of this page. The C# code for performing
- these kinds of interactions are quite simple. Like this:
+ of the screen to run arbitrary JavaScript code towards the context of this page. By default, the content
+ of the block below will be modified/inspected by the script code.
+
+ JavaScript integration
You can modify the value of this text field using JavaScript!
+
+ The C# code for performing these kinds of interactions is quite simple. Like this:
webBrowser.ExecuteScriptAsync(someScriptCode);- +
The code above will run the provided JavaScript snippet (which may do interesting things, like interrogating or modifying the DOM of the page, just to name one example out of many potential ones). The @@ -204,17 +208,17 @@
This is the preferrably approach if possible, since it does not deadlock the UI in any way. However, we realize that it's not suitable for all scenarios. Have faith — there is a solution even for cases where you do need to return a value. Just write your code like this:
- +var result = webBrowser.EvaluateScript("10 + 20");- +
Please note that only a limited number of data types are supported when returning the result above. Simple
value types (int, float, etc) and strings all work, but do not expect to be able to return other JavaScript
diff --git a/CefSharp.Wpf.Example/Views/Main/MainView.xaml b/CefSharp.Wpf.Example/Views/Main/MainView.xaml
index d2fe3aad11..b49fa55058 100644
--- a/CefSharp.Wpf.Example/Views/Main/MainView.xaml
+++ b/CefSharp.Wpf.Example/Views/Main/MainView.xaml
@@ -82,7 +82,7 @@
Grid.Row="0"
AcceptsReturn="True"
Margin="6"
- Text="alert('Hello World, do you copy?')">
+ Text="$('#modify-me').text('See how easy that was?')">