What is right place to inject custom JS in CefSharp for Ajax based site ?

1,050 views
Skip to first unread message

Tony Mullins

unread,
Feb 4, 2014, 10:05:52 AM2/4/14
to cefs...@googlegroups.com
Hi,

I need community's help on finding whats the best way to inject jQuery/Custom JS Script in CefSharp.

Currently I am injecting my script on  webView.LoadCompleted += webView_LoadCompleted . I think its not appropriate place to inject jQUery and custom script as in case of some Ajax based site this event is called multiple times and I want to insert my script at the end when complete site is loaded.

This is my script

var script = document.createElement('script');
script.src = 'http://code.jquery.com/jquery-latest.min.js';
document.body.appendChild(script);
jQuery.noConflict();

Is there any event in CefSharp which would let user know when page is complete loaded and ready for any JS manipulation ?

Thanks,
Tony

Jørn Hansen

unread,
Feb 4, 2014, 12:58:23 PM2/4/14
to cefs...@googlegroups.com


On Tuesday, February 4, 2014 4:05:52 PM UTC+1, Tony Mullins wrote:
I need community's help on finding whats the best way to inject jQuery/Custom JS Script in CefSharp.

Currently I am injecting my script on  webView.LoadCompleted += webView_LoadCompleted . I think its not appropriate place to inject jQUery and custom script as in case of some Ajax based site this event is called multiple times and I want to insert my script at the end when complete site is loaded.

 
Tony,  I guess the answer to your question is not specific to CefSharp but that help could also be found in the CEF forum since CefSharp builds on it. 

CefSharp is just a .NET wrapper on top of CEF so I assume CefSharp just notifies you with events received from CEF - and basically the DOM in Chromium which CEF wraps. Without understanding your scenario fully a few minutes of digging there brought me this which seems related:


Sorry, I'm quite new to CefSharp and CEF and guessing a bit here but hope this nonetheless will bring you towards an answer. Happy digging, and please post a followup here :-)

Best regards,
JornH
Reply all
Reply to author
Forward
0 new messages