Online Help
The Edge WebView2 object lets you display a web site on the page or dialog, just like it would appear in the Chromium-based Edge web browser. It does this by taking advantage of the Microsoft Edge WebView2 control that needs to be present on the target system.
Specifically, it embeds this control directly into your AutoPlay application at run time. This essentially places the Edge rendering engine on your page and uses it to display HTML in your application.
The end result is pretty much the same as what you would see in Edge itself, except that the desktop browser interface is not visible. Therefore it looks like the web page is built right into your application. You can use it to display online web content on the Internet, or to display locally stored web pages directly off a CD-ROM (or the user's hard drive).
The name that is used to identify this object.
The URL (or full path and filename) of the initial web page to display. This can be an HTML file, or any other type of file that can be viewed in a web browser. Click the browse button to select a file.
The actions that will be performed whenever the URL changes (when it starts to navigate to a new page) in the Edge object. Click the edit button to open the script editor.
The actions that will be performed whenever the URL being navigated to has finished loading. Click the edit button to open the script editor.
Navigates one page back in a Edge object.
(string) The name of the Edge object that you want to apply this action to.
Nothing. You can use Application.GetLastError to determine whether this action failed, and why.
Edge.Back("WebView");
Navigates one page forward in a Edge object.
(string) The name of the Edge object that you want to apply this action to.
Nothing. You can use Application.GetLastError to determine whether this action failed, and why.
Edge.Forward("WebView");
Returns the X and Y page or dialog coordinates of a Edge object in pixels. This coordinate refers to the upper left hand corner of the object's bounding box relative to the page or dialog.
Note: The upper left hand corner of a page or dialog has X and Y coordinates of 0.
(string) The name of the Edge object that you want to apply this action to.
(table) A table containing the object's current coordinates, indexed by values X and Y. If the object cannot be found, nil will be returned. You can use Application.GetLastError to determine whether this action failed, and why.
local tPos = Edge.GetPos("WebView"); Dialog.Message("Position", "X=" .. tPos.X .. ", Y=" .. tPos.Y);
Returns a table containing the properties of a Edge object.
(string) The name of the Edge object.
(table) A table containing the Edge object's properties, indexed by the following keys:
If the object cannot be found, nil will be returned. You can use Application.GetLastError to determine whether this action failed, and why.
-- get the currently loaded URL sURL = Edge.GetProperties("WebView").URL; -- Open the url in an external web browser File.OpenURL(sURL, SW_SHOWNORMAL);
Returns the pixel dimensions of a Edge object.
(string) The name of the Edge object.
(table) A table containing the object's pixel dimensions, indexed by values "Width" and "Height". If the object cannot be found, nil will be returned. You can use Application.GetLastError to determine whether this action failed, and why.
local tSize=Edge.GetSize("WebView"); Dialog.Message("Size", "Width=" .. tSize.Width .. ", Height=" .. tSize.Height);
Gets the URL that is currently displayed in a web object.
Note: If the web object is displaying a local file, this action will return the full path to that file in the standard URL format, i.e. file:/// followed by the full path to the file.
(string) The name of the Edge object.
(string) The URL of the file that is currently displayed in the Edge object. If an error occurs, a blank string "" is returned. You can use Application.GetLastError to determine whether this action failed, and why.
local sURL=Edge.GetURL("WebView"); Dialog.Message("URL", sURL);
Returns true if a specific Edge object is enabled, or false if it's disabled.
Note: When a Edge object is disabled, it doesn't respond to the user at all. The document cannot be clicked, zoomed or scrolled.
(string) The name of the Edge object that you want to apply this action to.
(boolean) True if the Edge object is enabled, false if it is disabled. If an error occurs, nil will be returned. You can use Application.GetLastError to determine whether this action failed, and why.
-- toggle the Edge object from enabled to disabled and vice-versa Edge.SetEnabled("WebView", not Edge.IsEnabled("WebView")); if Edge.IsEnabled("WebView") then Input.SetText("Status", "WebView is enabled"); else Input.SetText("Status", "WebView is disabled"); end
Returns true if a specific Edge object is silent, or false if it's not.
(string) The name of the Edge object that you want to apply this action to.
(boolean) True if the Edge object is silent, false if it is not. If an error occurs, nil will be returned. You can use Application.GetLastError to determine whether this action failed, and why.
local bRes = Edge.IsSilent("WebView");
Returns true if a specific Edge object is visible, or false if it's not.
(string) The name of the Edge object that you want to apply this action to.
(boolean) True if the Edge object is visible, false if it is hidden. If an error occurs, nil will be returned. You can use Application.GetLastError to determine whether this action failed, and why.
-- toggle state from visible to hidden and vice-versa Edge.SetVisible("WebView", not Edge.IsVisible("WebView")); if Edge.IsVisible("WebView") then Input.SetText("Status", "WebView is visible"); else Input.SetText("Status", "WebView is hidden"); end
Loads a string of HTML into a Edge object. In order for the action to succeed the Edge object must have a valid window handle. This means that the object must be visible and that this action should happen after the page's "On Show" event.
(string) The name of the Edge object that you want to apply this action to.
(string) The HTML that will be loaded into the Edge object.
Nothing. You can use Application.GetLastError to determine whether this action failed, and why.
Edge.LoadHTML("WebView", "<html><body><p>This is a test document.</p></body></html>");
Loads a local file or web-based URL into a Edge object.
Note: You cannot load a file or URL into a disabled web object. You must enable the object before loading the URL using the Web.SetEnabled action.
Note: If you want to use a named anchor on a relative path, it will fail. You must use the full path in order for this to work. For example, the following will not work:
Edge.LoadURL("Web1", "AutoPlay\\Docs\\index.html#news");
It must be specified as:
Edge.LoadURL("Web1", _SourceFolder.."\\AutoPlay\\Docs\\index.html#news");
(string) The name of the Edge object that you want to apply this action to.
(string) The URL for the web page, or the path to the local file.
Nothing. You can use Application.GetLastError to determine whether this action failed, and why.
Edge.LoadURL("WebView", "https://www.indigorose.com");
Allows to print the web page that is currently displayed in a Edge object. This action will open the "Print" dialog of the Edge browser, allowing to select printer, paper size and other settings.
(string) The name of the Edge object.
Nothing. You can use Application.GetLastError to determine whether this action failed, and why.
Edge.Print("WebView");
Reload the currently loaded page in the Edge object.
Note: This is just like clicking the "Refresh" button in the browser to reload the current web page, or pressing the F5 key.
(string) The name of the Edge object.
Nothing. You can use Application.GetLastError to determine whether this action failed, and why.
Edge.Refresh("WebView");
Sets the enabled/disabled state of a Edge object.
Note: When a Edge object is disabled, it doesn't respond to the user at all. The document cannot be clicked, zoomed or scrolled.
(string) The name of the Edge object that you want to apply this action to.
(boolean) Whether to make the Edge object enabled or disabled.
Nothing. You can use Application.GetLastError to determine whether this action failed, and why.
-- toggle the Edge object from enabled to disabled and vice-versa Edge.SetEnabled("WebView", not Edge.IsEnabled("WebView")); if Edge.IsEnabled("WebView") then Input.SetText("Status", "WebView is enabled"); else Input.SetText("Status", "WebView is disabled"); end
Sets the X and Y pixel coordinates of a Edge object relative to the page or dialog.
(string) The name of the Edge object that you want to apply this action to.
(number) The new X pixel coordinate (horizontal position) to set for the Edge object. This is the X coordinate of the upper left hand corner of the object's bounding box relative to the page or dialog.
(number) The new Y pixel coordinate (vertical position) to set for the Edge object. This is the Y coordinate of the upper left hand corner of the object's bounding box relative to the page or dialog.
Nothing. You can use Application.GetLastError to determine whether this action failed, and why.
Edge.SetPos("WebView", 10, 10); local tPos = Edge.GetPos("WebView"); Dialog.Message("", "X=" .. tPos.X .. ", Y=" .. tPos.Y);
Sets the properties of a Edge object.
(string) The name of the Edge object.
(table) A table containing the Edge object's properties, indexed by the following keys:
Nothing. You can use Application.GetLastError to determine whether this action failed, and why.
local tProps=Edge.SetProperties("WebView", { URL="https://google.com", Enabled=true, Visible=true, X=5, Y=5, Width=780, Height=500 });
Sets whether or not the Edge object will display dialogs, including error dialogs.
(string) The name of the Edge object that you want to apply this action to.
(boolean) Whether to make the web object silent.
Nothing. You can use Application.GetLastError to determine whether this action failed, and why.
-- suppress any error messages Edge.SetSilent("WebView");
Sets the size of a Edge object.
(string) The name of the Edge object that you want to apply this action to.
(number) The new width of the Edge object in pixels.
(number) The new height of the Edge object in pixels.
Nothing. You can use Application.GetLastError to determine whether this action failed, and why.
Edge.SetSize("WebView", 680, 450); local tSize=Edge.GetSize("WebView"); Dialog.Message("", "Width=" .. tSize.Width .. ", Height=" .. tSize.Height);
Sets the visibility of a Edge object.
Note: This option simply controls the visibility of Edge object. The object will continue to respond to actions even though it is hidden.
(string) The name of the Edge object that you want to apply this action to.
(boolean) Whether to make the Edge object visible or invisible.
Nothing. You can use Application.GetLastError to determine whether this action failed, and why.
Edge.SetVisible("WebView", not Edge.IsVisible("WebView")); if Edge.IsVisible("WebView") then Input.SetText("Status", "WebView is visible"); else Input.SetText("Status", "WebView is hidden"); end
Stops a Edge object.
Note: This is just like clicking the "Stop" button in the web browser to interrupt the current download.
(string) The name of the Edge object that you want to apply this action to.
Nothing. You can use Application.GetLastError to determine whether this action failed, and why.
Edge.Stop("WebView");
210301 - Could not find object.
210302 - Incorrect object type.
210303 - Invalid URL.
210304 - Cannot go back.
210305 - Cannot go forward.
210306 - Unable to call Lua function.
210307 - Cannot find Lua function.
210308 - Unable to find object window.
210309 - Cannot print current document.
Ulrich Peters
upeters@mindquake.com.br
The Edge WebView2 Object plugin is copyright © 2021 MindQuake Serviços de Informática.
Microsoft Edge WebView2
Getting started with WebView2
Reference (WebView2 Win32 C++)
Copyright © 2021 MindQuake Serviços de Informática.
All Rights Reserved.