Need help loading .js files referenced in a response stream.

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Need help loading .js files referenced in a response stream.

Postby Da1TruEcho » Mon Apr 24, 2017 6:17 pm

I'm using CEF 2883 in a multi process setup inside of a Windows MFC application. I have registered a custom scheme handler and streaming the response data to the browser. The problem I'm running into is the situation below.

My HTML has a script tag in the head with a src attribute set to a javascript file. I get an "Undefined" error whenever I try calling a function that is defined in that .js file.

For Example
<html>
<head>
<script src = "foo.js"/>
</head>
<body>
<script>
bar(); //bar is defined in foo.js
</script>
</body>
</html>

Dev tools shows an error saying "bar" is undefined. Am I missing something obvious?
Da1TruEcho
Techie
 
Posts: 14
Joined: Sun Mar 05, 2017 9:42 pm

Re: Need help loading .js files referenced in a response str

Postby amaitland » Mon Apr 24, 2017 8:28 pm

Stream the response data for your js file as well. Look at the source if you need an example
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1292
Joined: Wed Jan 14, 2015 2:35 am

Re: Need help loading .js files referenced in a response str

Postby Da1TruEcho » Mon Apr 24, 2017 10:51 pm

AH!!! That makes sense. Thank you!
Da1TruEcho
Techie
 
Posts: 14
Joined: Sun Mar 05, 2017 9:42 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 83 guests