Welcome Guest Search | Active Topics | Sign In | Register

How to embed jQuery to EO.WebBrowser as a built-in library Options
Khoa
Posted: Monday, April 20, 2015 6:18:27 PM
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.
eo_support
Posted: Monday, April 20, 2015 6:42:19 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
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.aspx

Thanks!
Khoa
Posted: Tuesday, April 21, 2015 5:06:53 PM
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.
eo_support
Posted: Wednesday, April 22, 2015 12:14:22 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
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!
Khoa
Posted: Thursday, April 23, 2015 7:58:21 AM
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.
eo_support
Posted: Thursday, April 23, 2015 9:36:40 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
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!
Khoa
Posted: Wednesday, May 6, 2015 4:15:03 PM
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.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.