|
Rank: Advanced Member Groups: Member
Joined: 9/3/2014 Posts: 68
|
Hi,
I would like to embed jQuery to EO.WebBrowser, so every page can use jQuery as an embedded JavaScript library without external reference. I try WebView.JSInitCode but it does not work.
Thank you.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,273
|
Hi, We won't troubleshoot your implementation for you. So we can only help you troubleshooting whether JSInitCode is working as expected. If that is not working, you can try to create a test project to demonstrate the problem and send it to us. Once we have that we will be happy to look further. See here for more details on how to send us test project: http://www.essentialobjects.com/forum/test_project.aspxThanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 9/3/2014 Posts: 68
|
Hi,
I sent you the test project. I hope you can check the problem for me.
Thank you.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,273
|
Hi, Thank you very much for the test project. Please change this line in your code:
Code: C#
webView1.JSInitCode = Properties.Resources.jquery;
To:
Code: C#
webView1.JSInitCode =
string.Format("window.setTimeout(function() {{ {0} }}, 5);", Properties.Resources.jquery);
The reason is JSInitCode is called very early at which time you can not modify the document's DOM tree yet. JQuery on the other hand, calls createElement in its initialization code. That part failed when you call JQuery code directly through JSInitCode. However using setTimeout to add a slight delay would make it work. Hope this helps. Please feel free to let us know if you still have any more questions. Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 9/3/2014 Posts: 68
|
This delay time trick works. Thank you. However, I got another case that it does not work. I already sent you the test project again.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,273
|
Hi,
It appears that this time it's the other way around --- the script got executed too late. We will look into this and see if we can remove the time delay so that your original code will work for both cases. We will let you know as soon as we have an update on this.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 9/3/2014 Posts: 68
|
Hi,
I would like to check any good news on this topic. Thank you.
|
|