I have a project that has a CHtmlView. This html view displays user customizable html files.

However from my program I want to supply variables (strings mainly) and/or provide functions that can be called from the javascript of the hosted pages.

The idea is that the javascript can then use those variables to dynamically generate the content the users want to be seeing in the form they want to see it.

Essentially... Start a new project in MFC.
Template: MFC application
In Generated classes: chance 'CView' to 'CHtmlView'.
Open the view class and change the Navigate2() call to point to a local html file.
create c:\test.html with following contents
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
    <title>Untitled Page</title>
<script type="text/jscript" language="jscript">
	function ConstructPage() {
		var mydiv = document.getElementById("MyDiv");
		mydiv.innerHTML = "MyVariableHere ?";
<body onload="ConstructPage();">
	<div id="MyDiv"></div>
Now, when running, I would like the "MyVariableHere?" be replaced by a variable (CString) that's being calculated from the C++ code. How do I set script variables from my C++ code" ?

The page doesn't need to autoupdate as the CString changes it just needs to be able to use the variables at load. If it could get updated values so you can set a timer in the script to keep a portion updated that would be awesome, but not required.