BembObject public properties & methods
|AllowScroll||Read/Write||Sets the AllowScroll property of the Web Browser control. This helps in making sure scrollbars don’t appear inside your hosted object. Alternatively, use a small margin on the html’s body element. Must be set before Initializing.|
|Document||ReadOnly||Returns the HTMLDocument object (equivalent to WebBrowserControl.Object.Document). Applicable only after Initialization.|
|jQueryNativeVersion||Read Only||Returns the version of jQuery used in the hosted page (currently all hosted pages require any fairly recent version of jQuery). Applicable only after Initialization.|
|SnippetsPath||Read/Write||Gets or Sets the path to the Snippets file to be used. Can be used before or after Initialization.|
|SnippetStartQualifier||Read/Write||Gets or Sets the start qualifier to be used for the Snippets file. Default /// StartSnippet: Can be used before or after Initialization.|
|Eval||String||CodeToRun, Optional PostFunction||Runs the specified code (and optional function to run after the code) and returns the value|
|EventReceived||N/A||N/A||Do Not Use! This exists as a requirement for the internal Event Handler. Leave this alone…|
|ExecScript||N/A||None||Executes the specified script|
|GetSnippet||String||SnippetName||Returns the contents of the specified Snippet, or ZLS if not present. See SnippetsPath and SnippetStartQualifier properties, as well as the Snippets section of this documentation for more information.|
|Init||N/A||SubformContainer, URL||Initializes the object. Takes the subform that will serve as the object container and the URL to the page to display (current version doesn’t support page navigating).|
|LoadScriptFileToString||String||FilePath||Loads the contents of a text file into a string. Useful for loading files.|
|Initialized||None||Raised after the object and framework are fully initialized. Use this event to set up your event handlers and any other tasks that might require the hosted page to be present.|
Currently (as of v0.5.0.0), jQuery handling is rudimentary but required. The hosted page *must* include some jQuery library of reasonable recency (figure on jQuery 1.7+ being ok, I haven’t fully tested how far back we can go though).
Future plans do involve better support for jQuery, but are currently not implemented. However, you can access the version of jQuery being used through the bemb’s jQueryNativeVersion property.
How it Works
Quite simply, the Snippets feature points to a file, there’s a specific string used to denote the start of a Snippet (by default: /// SnippetStart: [snippetNameHere]). Everything after that start line, up to the next found start line or the EOF, is returned.
You can change the start line by setting the SnippetStartQualifier property, and you can change the snippets file path by using the SnippetsPath property. Use the GetSnippet()method to get the snippet you need.
Example from ChartJS demo
/// StartSnippet: WindowResizedHandlerSnippet
Canvas.width = window.innerWidth;
Canvas.height = window.innerHeight;
/// StartSnippet: ChartClickHandlerSnippet
var points = window.myLine.getPointsAtEvent(event);
bembData = points.value + ', ' + points.value;
/// StartSnippet: RefreshChartDataBuild
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'],
label: 'Dataset 1 Name',
label: 'Dataset 2 Name',
The bemb download package contains two modules that can help with setting up the registry for IE11 Emulation Mode. See the QuickStart page for details.
Notes on setting the registry values:
- Key: HKCUSoftwareMicrosoftInternet ExplorerMainFeatureControlBROWSER_FEATURE_EMULATION
- Value: DWORD “msaccess.exe” 11999 (0x2edf or 2edf)
- The Registry setting can be made under either HKLM or HKCU. HKCU is preferred in that it doesn’t require admin privileges (many thanks to Tom van Stiphout for working this out). The BembRegistry module uses the HKCU hive and is intended as an easy way to run a client location for manual setup.
- Distribution should be relatively easy, in terms of Registry requirements anyway. One could either use their own little install routine that makes use of the code that’s in the BembRegistry module, or this value could be set as part of an installer’s script.
- Important! This emulation mode is required to be set for the msaccess.exe executable, which means that any Access programs that may run on this computer will use the emulation mode set here. This shouldn’t generally be a problem, but is definitely worth keeping in mind. In a worst case scenario, you may want to include code to remove/reset the value on your application shutdown. In an absolute worst case scenario, you may want to create an executable wrapper which calls your Access program and enter the Registry value under that executable name (note: I have not tried this and am not sure it will work).