Description
The DHTML control wraps the internal web engine, supports calling Javascript functions from Lua,
as well as running Lua from within the HTML. Running Lua code is disabled by default.
View source
Parent
Derives methods, etc not listed on this page from HTML.
Implements
Implements or overrides the following hooks/methods. If you want to override these, you probably want to call the original function too.
Methods
Defines a Javascript function that when called will call a Lua callback.
Note: Must be called after the HTML document has fully loaded.
Runs/Executes a string as JavaScript code in a panel.
Note: This function does NOT evaluate expression (i.e. allow you to pass variables from JavaScript (JS) to Lua context).Because a return value is nil/no value (a.k.a. void).If you wish to pass/return values from JS to Lua, you may want to use DHTML:AddFunction function to accomplish that job.Note: This function is an alias of DHTML:QueueJavascript (source).
Returns if the loaded page can run Lua code, set by DHTML:SetAllowLua
Deprecated: We advise against using this. It may be changed or removed in a future update.
Broken. Use the CSS overflow rule instead.
Returns the value set by DHTML:SetScrollbars.
Runs/Executes a string as JavaScript code in a panel.
Note: This function does NOT evaluate expression (i.e. allow you to pass variables from JavaScript (JS) to Lua context).Because a return value is nil/no value (a.k.a. void).If you wish to pass/return values from JS to Lua, you may want to use DHTML:AddFunction function to accomplish that job.Note: If Panel:IsVisible is false, PANEL:Think will NOT run, meaning the Javascript Queue will not be processed.Consider overriding PANEL:Paint to stop the panel from drawing instead.
Determines whether the loaded page can run Lua code or not. See DHTML for how to run Lua from a DHTML window.
Deprecated: We advise against using this. It may be changed or removed in a future update.
Broken. Use the CSS overflow rule instead.
Sets if the loaded window should display scrollbars when the webpage is larger than the viewing window. This is similar to the CSS overflow rule.
Awesomium doesn’t work with most HTTPS websites because it only supports up to TLS 1.0.
This and other rendering issues can be rectified by using the x86-64 branch.
Using url/href/src
You might have noticed that Relative File Paths like <img src="/images/picture.jpg"> wont work. There are 3 solutions for that:
asset://
Instead of https:// we use asset:// which will point to our local files.
<img src="asset://garrysmod/materials/example_addon/example.png">
Please don't point towards your Addons folder. Use the File Location where Gmod has your addon files included.
Online
Classic Absolute File Paths still work ... well unless you are offline or the website is down or the website uses HTTPS above TLS 1.0 Version.
<img src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png">
Base64 encoding
This will encode your local File into a Base64 String. The String will start with the datatype like data:image/jpeg;base64, followed by a long chain of characters being the Base64 data.
<img src="data:image/jpeg;base64,LzlqLzRBQ...<!-- base64 data -->">
url("data:image/jpeg;base64,LzlqLzRBQ...<!-- base64 data -->")
Websites like https://www.base64-image.de/ can encode the file for you.
Examples
Example
Example
Creates a DHTML and opens Google inside.
Output: 