Garry's Mod Wiki

HTML

Description

The HTML control can be used to display web pages just like an internet browser.

DHTML has additional functionality for interfacing with the page, such as sending and receiving data.

Blocked URL Extentions

This means your url cannot end in any of these extensions, e.g.: (http://yourdomain.com/garry.exe)

  • .exe
  • .bat
  • .dll
  • .zip
  • .mp3
  • .swf

Parent

Derives methods, etc not listed on this page from Panel.

Events

HTML:ConsoleMessage( string msg, string file, number lineNr, string severity )
Called when the page inside the HTML window runs the console.log javascript function. On the x86-64 beta, it's called for all built-in console.* javascript functions. Overwriting this function in any way will disable default behavior of printing the message to the in-game console.
Called when this panel begins loading a page.
boolean HTML:OnCallback( string library, string name, table arguments )
Called by the engine when a callback function is called.
Called when this panel's address changes.
Called by HTML panels when the target URL of the frame has changed, this happens when you hover over a link.
HTML:OnChangeTitle( string newTitle )
Called by HTML panels when the title of the loaded page has been changed.
HTML:OnChildViewCreated( string sourceURL, string targetURL, boolean isPopup )
Called by HTML panels when the page attempts to open a new child view (such as a popup or new tab).
HTML:OnDocumentReady( string url )
Called by HTML panels when the panel's DOM has been set up. You can run JavaScript in here.
Called when this panel successfully loads a page.

Example

Creates an HTML control in the center of screen, and makes it display http://wiki.garrysmod.com/

concommand.Add( "test_html", function() local frame = vgui.Create( "DFrame" ) -- The name of the panel we don't have to parent it. frame:SetPos( 100, 100 ) -- Set the position to 100x by 100y. frame:SetSize( 500, 500 ) -- Set the size to 300x by 200y. frame:SetTitle( "HTML Test" ) -- Set the title in the top left to "Derma Frame". frame:MakePopup() -- Makes your mouse be able to move around. local HTMLTest = vgui.Create( "HTML", frame ) HTMLTest:Dock( FILL ) HTMLTest:OpenURL( "http://wiki.garrysmod.com" ) end )