IupWebBrowser [GTK and Windows only] (since 3.3)

Creates a web browser control. It is responsible for managing the drawing of the web browser content and forwarding of its events.

In Linux, the implementation uses the WebKit/GTK+, the new GTK+ port of the WebKit, an open-source web content engine. More information about WebKit/GTK+ (building, dependencies, releases, etc) can be seen in Notes section. It is only available for Linux26g4 and Linux26g4_64 systems.

In Windows, the implementation uses the IupOleControl to embed an instance of the Internet Explorer WebBrowser control. A listener interface is used to capture and handle events using the Active Template Library (ATL) classes. More information about ATL can be seen in Notes section. So it is only available for Visual C++ compilers.

Initialization and usage

The IupWebBrowserOpen function must be called after IupOpen. The iupweb.h file must also be included in the source code. The program must be linked to the controls library (iupweb). If static linking is used then in Windows must be linked with the "iupole" library and in Linux must be linked with the "webkit-1.0" library

To make the control available in Lua use require"iupluaweb" or manually call the initialization function in C, iupweblua_open, after calling iuplua_open. When manually calling the function the iupluaweb.h file must also be included in the source code, and the program must be linked to the lua control library (iupluaweb).

Creation

Ihandle* IupWebBrowser(void); [in C]
iup.webbrowser{} -> (ih: ihandle) [in Lua]
webbrowser() [in LED]

Returns: the identifier of the created element, or NULL if an error occurs.

Attributes

BACKCOUNT [GTK Only] (read only): gets the number of items that precede the current page.

BACKFORWARD (write only): sets the number of steps away from the current page and loads the history item. Negative values represent steps backward while positive values represent steps forward.

COPY (write only): copy the selection to the clipboard. (since 3.10)

FORWARDCOUNT [GTK Only] (read only): gets the number of items that succeed the current page.

HTML (write only): loads a given HTML content.

ITEMHISTORYid [GTK Only] (read only): Returns the URL associated with a specific history item. Negative "id" value represents a backward item while positive "id" value represents a forward item ("0" represents the current item).

PRINT (write only): shows the print dialog. (since 3.10)

RELOAD (write only): reloads the page in the webbrowser.

SELECTALL (write only): selects all contents. (since 3.10)

STATUS (read only): returns the load status. Can be "LOADING", "COMPLETED" or "FAILED".

STOP (write only): stops any ongoing load in the webbrowser.

VALUE: sets a specified URL to load into the webbrowser, or retrieve the current URL.

ZOOM: the zoom factor of the browser in percent. No zoom is 100%. (since 3.10)


ACTIVE, FONT, EXPAND, SCREENPOSITION, POSITION, MINSIZE, MAXSIZE, WID, TIP, RASTERSIZE, ZORDER, VISIBLE: also accepted.

Callbacks

COMPLETED_CB: action generated when a page successfully completed. Can be called multiple times when a frame set loads its frames, or when a page loads also other pages.

int function(Ihandle* ih, char* url);  [in C]
ih:completed_cb(url) -> (ret: number) [in Lua]

ih: identifier of the element that activated the event.
url: the URL address that completed.

ERROR_CB: action generated when page load fail.

int function(Ihandle* ih, char* url);  [in C]
ih:error_cb(url) -> (ret: number) [in Lua]

ih: identifier of the element that activated the event.
url: the URL address that caused the error.

NAVIGATE_CB: action generated when the browser requests a navigation to another page. It is called before navigation occurs. Can be called multiple times when a frame set loads its frames, or when a page loads also other pages.

int function(Ihandle* ih, char* url);  [in C]
ih:navigate_cb(url) -> (ret: number) [in Lua]

ih: identifier of the element that activated the event.
url: the URL address to navigate to.

Returns: IUP_IGNORE will abort navigation (since 3.4).

NEWWINDOW_CB: action generated when the browser requests a new window.

int function(Ihandle* ih, char* url);  [in C]
ih:newwindow_cb(url) -> (ret: number) [in Lua]

ih: identifier of the element that activated the event.
url: the URL address that is opened in the new window.


MAP_CB, UNMAP_CB, DESTROY_CB, GETFOCUS_CB, KILLFOCUS_CB, ENTERWINDOW_CB, LEAVEWINDOW_CB, K_ANY, HELP_CB: All common callbacks are supported.

Notes

To learn more about WebKit and WebKitGTK+:

The WebKit Open Source Project
The WebKitGTK+ web page
WebKitGTK+ wiki
WebKitGTK+ tracker

To learn more about Internet Explorer WebBrowser control and ATL:

WebBrowser Control from C/C++
Creating ATL sinks
Examples of sinking COM events

Examples

Browse for Example Files