wWebView

This control may be used to render web (HTML / CSS / javascript) documents. As an embedded internet explorer, you can use getComObject() to get a winim COM object with IWebBrowser2 interface and then do a lot of thing on it. For example, manipulate DOM, call javascript function, and so on.

By default, the control runs in compatibility view mode (IE7). To change the compatibility mode, you need to deal with the registry key: FEATURE_BROWSER_EMULATION.

Notice: wWebView is always re-enabled before wEvent_WebViewLoaded event. If you need a disabled control, disable it again in the event handler of wEvent_WebViewLoaded.

Appearance:
Superclass:wControl
Styles:
StylesDescription
wWvNoSelDoes not enable selection of the text.
wWvNoScrollDoes not have scroll bars.
wWvNoContextMenuDoes not have context menus.
wWvNoFocusDoes not receive focus.
wWvSilentDoes not display dialog boxes (script error, etc.).
Events:wWebViewEvent

Types

wWebViewError = object of wError
  
An error raised when webview operation failure.

Procs

proc navigate(self: wWebView; url: string; noHistory = false) {...}{.raises: [Exception],
    tags: [RootEffect].}
Navigating the given url.
proc runScript(self: wWebView; code: string) {...}{.raises: [Exception, wWebViewError],
    tags: [RootEffect].}
Runs the given javascript code. This function discard the result. If you need the result from the javascript code, use eval instead. For example:
var obj = webView.getComObject()
echo obj.document.script.call("eval", "1 + 2 * 3")
proc getHtml(self: wWebView): string {...}{.raises: [Exception, wWebViewError],
                                   tags: [RootEffect].}
Get the HTML source code of the currently displayed document.
proc setHtml(self: wWebView; html: string) {...}{.raises: [Exception, wWebViewError],
                                        tags: [RootEffect].}
Set the displayed page HTML source to the contents of the given string.
proc canGoBack(self: wWebView): bool {...}{.inline, raises: [], tags: [].}
Returns true if it is possible to navigate backward.
proc canGoForward(self: wWebView): bool {...}{.inline, raises: [], tags: [].}
Returns true if it is possible to navigate forward.
proc goBack(self: wWebView) {...}{.inline, raises: [Exception], tags: [RootEffect].}
Navigate back.
proc goForward(self: wWebView) {...}{.inline, raises: [Exception], tags: [RootEffect].}
Navigate forward.
proc refresh(self: wWebView) {...}{.inline, raises: [Exception], tags: [RootEffect].}
Navigate forward.
proc stop(self: wWebView) {...}{.inline, raises: [Exception], tags: [RootEffect].}
Stop the current page loading process.
proc isBusy(self: wWebView): bool {...}{.raises: [Exception], tags: [RootEffect].}
Returns whether the web control is currently busy.
proc getCurrentUrl(self: wWebView): string {...}{.raises: [Exception], tags: [RootEffect].}
Get the URL of the currently displayed document.
proc getCurrentTitle(self: wWebView): string {...}{.raises: [Exception, wWebViewError],
    tags: [RootEffect].}
Get the title of the current web page, or its URL/path if title is not available.
proc getText(self: wWebView): string {...}{.raises: [Exception, wWebViewError],
                                   tags: [RootEffect].}
Get the text of the current page.
proc getSelectedHtml(self: wWebView): string {...}{.raises: [Exception, wWebViewError],
    tags: [RootEffect].}
Returns the currently selected HTML source.
proc getSelectedText(self: wWebView): string {...}{.raises: [Exception, wWebViewError],
    tags: [RootEffect].}
Returns the currently selected text.
proc clearSelection(self: wWebView) {...}{.raises: [Exception, wWebViewError],
                                   tags: [RootEffect].}
Clears the current selection.
proc selectAll(self: wWebView) {...}{.inline, raises: [Exception, wWebViewError],
                              tags: [RootEffect].}
Selects the entire page.
proc canCopy(self: wWebView): bool {...}{.inline, raises: [Exception, wWebViewError],
                                 tags: [RootEffect].}
Returns true if the current selection can be copied.
proc copy(self: wWebView) {...}{.inline, raises: [Exception, wWebViewError],
                         tags: [RootEffect].}
Copies the current selection.
proc init(self: wWebView; parent: wWindow; id = wDefaultID; pos = wDefaultPoint;
         size = wDefaultSize; style: wStyle = 0) {...}{.raises: [wNilAccess, wWindowError,
    wCursorError, wBrushError, Exception, IndexDefect, wFontError],
    tags: [RootEffect].}
Initializes a webview control.
proc WebView(parent: wWindow; id = wDefaultID; pos = wDefaultPoint; size = wDefaultSize;
            style: wStyle = 0): wWebView {...}{.inline, discardable, raises: [wNilAccess,
    wWindowError, wCursorError, wBrushError, Exception, IndexDefect, wFontError],
                                      tags: [RootEffect].}
Constructor.

Methods

method getDefaultSize(self: wWebView): wSize {...}{.raises: [Exception], tags: [RootEffect].}
Returns the default size for the control.
method getBestSize(self: wWebView): wSize {...}{.raises: [Exception], tags: [RootEffect].}
Returns the best acceptable size for the control.
method release(self: wWebView) {...}{.raises: [], tags: [].}
Release all the resources during destroying. Used internally.

Templates

template getComObject(self: wWebView): untyped
Returns a winim COM object with IWebBrowser2 interface. Import winim/com before using this template.
template comObject(self: wWebView): untyped
The same as getComObject().