How to adjust each other between c # and js in WebKit.Net winform program
This article shows you how to tune c # and js in the WebKit.Net winform program, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Lab 1:
Button 1 event:
CurrentPage.browser.DocumentText =
"Test Page" +
"Hello, World!
"+
"
A
B
C
"+
"" +
"function f () {window.open ('http://www.pudn.com/Download/item/id/2111740.html',' myWindow');}" +
"
Button 2 event:
CurrentPage.browser.StringByEvaluatingJavaScriptFromString ("f ()")
So when you click button 1 and then click button 2, you will jump to pudn. The experiment was successful.
Lab 2:
There is an index.html file under tomcat's webapps/ROOT:
TitleHello, World!
A
B
C
Hello world spring boot3function f () {window.open ('https://www.baidu.com',' myWindow');}
In the button event:
CurrentPage.browser.IsScriptingEnabled = true
CurrentPage.browser.StringByEvaluatingJavaScriptFromString ("f ()")
Can successfully jump to baidu. Browser_NewWindowRequest and browser_NewWindowCreated events can be executed, but browser_DocumentCompleted cannot be executed unless browse performs a refresh operation.
Https://bbs.csdn.net/topics/390962337/ and https://sourceforge.net/p/webkitdotnet/discussion/939856/thread/daaed049/ talk about 64-bit BUG, or multithreading, and all my experiments are abnormal.
Private void newWindowToolStripMenuItem_Click (object sender, EventArgs e) {if (MessageBox.Show ("This is likely to cause a crash. Continue? "," Warning ", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = = DialogResult.Yes) {var thread = new Thread (new ThreadStart (MyThread)); thread.SetApartmentState (ApartmentState.STA); thread.Start ();}} private void MyThread () {Application.Run (new MainForm ()) }
It seems that setting ApartmentState.STA in this way does not work.
The above is how to adjust c # and js in the WebKit.Net winform program. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.