Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement LoadHandler.OnDomReady #32

Open
GoogleCodeExporter opened this issue Aug 28, 2015 · 4 comments
Open

Implement LoadHandler.OnDomReady #32

GoogleCodeExporter opened this issue Aug 28, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

GoogleCodeExporter commented Aug 28, 2015

UPDATE: Such functionality is implemented in the "ondomready.py" snippet available in the examples/snippets/ directory.

Seems that OnLoadEnd is not the same as DOMContentLoaded, when testing loading of big image it behaves more like window.onload. We need a built-in event when DOM is ready. We should inject javascript to listen for DOMContentLoaded, it is the event used by jQuery.ready().

See this topic on CEF forum for more details:
https://magpcss.org/ceforum/viewtopic.php?f=6&t=10277

@GoogleCodeExporter
Copy link
Author

GoogleCodeExporter commented Aug 28, 2015

This post shows an example of using the CEF DOM API for hooking up to the DOMContentLoaded event:

https://magpcss.org/ceforum/viewtopic.php?p=17302#p17302

This can also be done in javascript and communicated back with native code through js bindings. In OnLoadStart() call ExecuteJavascript() that adds an event listener for DOMContentLoaded, this listener will call window.CefPython.OnDomReady() that is a js binding. Though, with the current CEF Python JS binding implementation not every browser has a JavascriptBindings object set, it is being done explicitily by user, this complicates things a bit. What if the browser doesn't have js binding object set, what if we set it, but user overwrites it later? This solution should not mess up with user js bindings object.

The example that uses the CEF DOM API looks much easier to implement.

@GoogleCodeExporter
Copy link
Author

GoogleCodeExporter commented Aug 28, 2015

See also CEF Issue 1454 "Add callback for document element creation":
https://code.google.com/p/chromiumembedded/issues/detail?id=1454

@cztomczak
Copy link
Owner

cztomczak commented Aug 19, 2017

When Issue #391 ("Implement Frame.GetProperty/SetProperty methods") gets implemented it will be easier to expose this new LoadHandler.OnDomReady method.

@cztomczak
Copy link
Owner

Such functionality is implemented in the "ondomready.py" snippet available in the examples/snippets/ directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants