问题
I use CEF(chromium ebedded Framework) load a html page:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script src="phantom-limb.js" type="text/javascript"></script>
</body>
</html>
and it works ok. now, I modify the page as follow:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
</html>
and after cef loaded it, I use cef's ExecuteJavaScript method to execute the same phantom-limb.js, but nothing appear.
how can I load the js file and execute, or, the js file has some limit?
thx:)
回答1:
As you can see at the end of the source code of you JS file, the startOnLoad
config parameter is set to true
by default.
In this way a listener to the DOMContentLoaded
is added, which is never called because your page is already loaded.
So, you just have to append the line start();
to your source code, then call your ExecuteJavaScript
and it will work even after the page is loaded.
来源:https://stackoverflow.com/questions/29191363/how-to-load-a-js-file-and-execute-it-on-cef