API-Version: 1.9

WebKitWebView

GtkWidget that shows webcontent

new WebKitWebView()

A GtkWidget that shows the webcontent

Source:

Extends

Members

allFrames :Array[WebKitWebFrame]

All frames of a webview, including the main frame

Source:

focusedFrame :WebKitWebFrame

The focused frame

Source:

hasSelection :Boolean

Whether text is selected in the webview

Source:

historyList :WebKitWebBackForwardList

The history of the webview

Source:

lastSearch :String

The last search string of the webview

Source:

mainFrame :WebKitWebFrame

The main frame

Source:

number :Number

The tabnumber of the webview, starting at 0

Source:

onButtonPress :function

Connects the webview for the buttonPress event, see onButtonPress. Can be set multiple times.

Since:
  • 1.7
Source:

onButtonRelease :function

Connects the webview for the buttonRelease event, see onButtonRelease. Can be set multiple times.

Since:
  • 1.7
Source:

onceButtonPress :function

Connects the webview for the buttonPress event once, see onButtonPress. Can be set multiple times.

Since:
  • 1.7
Source:

onceButtonRelease :function

Connects the webview for the buttonRelease event once, see onButtonRelease. Can be set multiple times.

Since:
  • 1.7
Source:

onceCloseTab :function

Connects the webview for the closeTab event once, see onCloseTab. Can be set multiple times.

Since:
  • 1.7
Source:

onceContextMenu :function

Connects the webview for the contextMenu event once, see onContextMenu. Can be set multiple times.

Since:
  • 1.7
Source:

onceDocumentLoaded :function

Connects the webview for the documentLoaded event once, see onDocumentLoaded. Can be set multiple times.

Since:
  • 1.7
Source:

onceDownload :function

Connects the webview for the download event once, see onDownload. Can be set multiple times.

Since:
  • 1.7
Source:

onceError :function

Connects the webview for the error event once, see onError. Can be set multiple times.

Since:
  • 1.7
Source:

onceFollowHint :function

Connects the webview for the followHint event once, see onFollowHint. Can be set multiple times.

Since:
  • 1.7
Source:

onceFrameCreated :function

Connects the webview for the frameCreated event once, see onFrameCreated. Can be set multiple times.

Since:
  • 1.7
Source:

onceFrameStatus :function

Connects the webview for the frameStatus event once, see onFrameStatus. Can be set multiple times.

Since:
  • 1.7
Source:

onceKeyPress :function

Connects the webview for the keyPress event once, see onKeyPress. Can be set multiple times.

Since:
  • 1.7
Source:

onceKeyRelease :function

Connects the webview for the keyRelease event once, see onKeyRelease. Can be set multiple times.

Since:
  • 1.7
Source:

onceLoadCommitted :function

Connects the webview for the loadCommitted event once, see onLoadCommitted. Can be set multiple times.

Since:
  • 1.7
Source:

onceLoadFinished :function

Connects the webview for the loadFinished event once, see onLoadFinished. Can be set multiple times.

Since:
  • 1.7
Source:

onceLoadStatus :function

Connects the webview for the loadStatus event once, see onLoadStatus. Can be set multiple times.

Since:
  • 1.7
Source:

onceMimeType :function

Connects the webview for the mimeType event once, see onMimeType. Can be set multiple times.

Since:
  • 1.7
Source:

onceMouseMove :function

Connects the webview for the mouseMove event once, see onMouseMove. Can be set multiple times.

Since:
  • 1.7
Source:

onceNavigation :function

Connects the webview for the navigation event once, see onNavigation. Can be set multiple times.

Since:
  • 1.7
Source:

onceResource :function

Connects the webview for the resource event once, see onResource. Can be set multiple times.

Since:
  • 1.7
Source:

onceScroll :function

Connects the webview for the scroll event once, see onScroll. Can be set multiple times.

Since:
  • 1.7
Source:

onceTabButtonPress :function

Connects the webview for the tabButtonPress event once, see onTabButtonPress. Can be set multiple times.

Since:
  • 1.7
Source:

onceTabFocus :function

Connects the webview for the tabFocus event once, see onTabFocus. Can be set multiple times.

Since:
  • 1.7
Source:

onCloseTab :function

Connects the webview for the closeTab event, see onCloseTab. Can be set multiple times.

Since:
  • 1.7
Source:

onContextMenu :function

Connects the webview for the contextMenu event, see onContextMenu. Can be set multiple times.

Since:
  • 1.7
Source:

onDocumentLoaded :function

Connects the webview for the documentLoaded event, see onDocumentLoaded. Can be set multiple times.

Since:
  • 1.7
Source:

onDownload :function

Connects the webview for the download event, see onDownload. Can be set multiple times.

Since:
  • 1.7
Source:

onError :function

Connects the webview for the error event, see onError. Can be set multiple times.

Since:
  • 1.7
Source:

onFollowHint :function

Connects the webview for the followHint event, see onFollowHint. Can be set multiple times.

Since:
  • 1.7
Source:

onFrameCreated :function

Connects the webview for the frameCreated event, see onFrameCreated. Can be set multiple times.

Since:
  • 1.7
Source:

onFrameStatus :function

Connects the webview for the frameStatus event, see onFrameStatus. Can be set multiple times.

Since:
  • 1.7
Source:

onKeyPress :function

Connects the webview for the keyPress event, see onKeyPress. Can be set multiple times.

Since:
  • 1.7
Source:

onKeyRelease :function

Connects the webview for the keyRelease event, see onKeyRelease. Can be set multiple times.

Since:
  • 1.7
Source:

onLoadCommitted :function

Connects the webview for the loadCommitted event, see onLoadCommitted. Can be set multiple times.

Since:
  • 1.7
Source:

onLoadFinished :function

Connects the webview for the loadFinished event, see onLoadFinished. Can be set multiple times.

Since:
  • 1.7
Source:

onLoadStatus :function

Connects the webview for the loadStatus event, see onLoadStatus. Can be set multiple times.

Since:
  • 1.7
Source:

onMimeType :function

Connects the webview for the mimeType event, see onMimeType. Can be set multiple times.

Since:
  • 1.7
Source:

onMouseMove :function

Connects the webview for the mouseMove event, see onMouseMove. Can be set multiple times.

Since:
  • 1.7
Source:

onNavigation :function

Connects the webview for the navigation event, see onNavigation. Can be set multiple times.

Since:
  • 1.7
Source:

onResource :function

Connects the webview for the resource event, see onResource. Can be set multiple times.

Since:
  • 1.7
Source:

onScroll :function

Connects the webview for the scroll event, see onScroll. Can be set multiple times.

Since:
  • 1.7
Source:

onTabButtonPress :function

Connects the webview for the tabButtonPress event, see onTabButtonPress. Can be set multiple times.

Since:
  • 1.7
Source:

onTabFocus :function

Connects the webview for the tabFocus event, see onTabFocus. Can be set multiple times.

Since:
  • 1.7
Source:

scrolledWindow :GtkScrolledWindow

The parent widget of every webview, it is used for scrolling the webview

Source:

tabBox :GtkBox

Horizontal box, child of wv.tabWidget.

Source:

tabIcon :GtkImage

Favicon widget, child of wv.tabBox

Source:

tabLabel :GtkLabel

Text label of a tab, child of wv.tabBox.

Source:

tabWidget :GtkEventBox

The main widget for tab labels, used for coloring tabs, child of gui.tabBox.

Source:

Methods

blockSignal(id)

Blocks emission of a signal

Parameters:
Name Type Description
id Number

The signal id retrieved from GObject#connect

Inherited From:
Source:

connect(name, callback, after) → {Number}

Connect to a GObject-signal. Note that all signals are connected using the signal::- or with notify::-prefix. If connecting to a signal the signal::-prefix must be omitted. The callback function will have the same parameters as the GObject signal callback without the first parameter, however some parameters may be undefined if they cannot be converted to javascript objects. All signal handlers are executed after dwb’s default handler.

Parameters:
Name Type Argument Description
name String

The signal name.

callback GObject~connectCallback

Callback that will be called when the signal is emitted.

after Boolean <optional>

Whether to connect after the default signal handler.

Inherited From:
Source:
Returns:

The signal id of this signal

Type
Number

connectBlocked(name, callback, after) → {Number}

Connect to a gobject-signal but block the emission of the own callback during execution of the callback. Useful if the object is connected to a notify event and the the property is changed in the callback function.

Parameters:
Name Type Argument Description
name String

The signal name.

callback Function

Callback that will be called when the signal is emitted.

after Boolean <optional>

Whether to connect after the default signal handler.

Inherited From:
Source:
Returns:

The signal id of this signal

Type
Number

disconnect(id) → {Boolean}

Disconnects from a signal

Parameters:
Name Type Description
id Number

The signal id retrieved from GObject.connect

Inherited From:
Source:
Returns:

Whether a signal was found and disconnected

Type
Boolean

history(steps)

Loads a history item, can be used to navigate forward/backwards in history

Parameters:
Name Type Description
steps Number

Number of steps, pass a negative value to go back in history

Source:

inject(code, arg, line, global) → {String}

Injects javascript code into a frame or webview

Parameters:
Name Type Argument Description
code String | Function

The script to inject, either a string or a function. If it is a function the body will be wrapped inside a new function.

arg Object

If the script isn’t injected into the global scope the script is wrapped inside a function. arg then is accesible via arguments in the injected script, or by the variable exports, optional

line Number <optional>

Starting line number, useful for debugging. If linenumber is greater than 0 error messages will be printed to stderr, optional.

global Boolean <optional>

true to inject it into the global scope, false to encapsulate it in a function, default false

Source:
Returns:

The return value of the script. If the script is injected globally inject always returns null. The return value is always converted to a string. To return objects call JSON.parse on the return value.

Type
String
Example
 
//!javascript
function injectable() {
   var text = exports.text;
   document.body.innerHTML = text;
}
signals.connect("documentLoaded", function(wv) {
   wv.inject(injectable, { text : "foo", number : 37 }, 3);
});

loadString(content, mimeType, encoding, baseUri, externalSources) → {Deferred}

Loads a string in a frame or a webview

Parameters:
Name Type Argument Description
content String

The string to load

mimeType String <optional>

The MIME-type, if omitted or null text/html is assumed.

encoding String <optional>

The character encoding, if omitted or null UTF-8 is assumed.

baseUri String <optional>

The base uri, if present it must either use the uri-scheme dwb-chrome: or file:, otherwise the request will be ignored.

externalSources boolean <optional>

Whether external sources, e.g. scripts, are allowed, defaults to false. If external resources are forbidden the function dwb can be called in the webcontext to execute functions in the scripting context

Since:
  • 1.3
Source:
Returns:

A deferred that will be resolved if the webview has finished loading the string and rejected if an error occured

Type
Deferred

loadUri(uri, callback) → {Boolean}

Load an uri in a webview

Parameters:
Name Type Argument Description
uri String

The uri to load

callback WebKitWebView#loadUriCallback <optional>

A callback function that will be called when the load status changes, return true to stop the emission

Source:
Returns:

true if the uri was loaded

Type
Boolean

notify(name, callback, after) → {Number}

Connects to a property change notification

Parameters:
Name Type Argument Description
name String

The property name, can also be in camelcase.

callback GObject~notifyCallback

Callback that will be called when the property changes

after Boolean <optional>

Whether to connect after the default handler.

Inherited From:
Source:
Returns:

The signal id of this signal

Type
Number

notifyBlocked(name, callback, after) → {Number}

Connects to a property change notification but with signal blocking. Must be used if the property is modified in the callback function.

Parameters:
Name Type Argument Description
name String

The property name, can also be in camelcase.

callback GObject~notifyCallback

Callback that will be called when the property changes

after Boolean <optional>

Whether to connect after the default handler.

Inherited From:
Deprecated:
  • Yes
Source:
Returns:

The signal id of this signal

Type
Number
Example
 
gui.statusLabel.notifyBlocked("label", function() {
     this.label += "foo"; 
});

reload()

Reloads the current site

Source:

stopLoading()

Stops any ongoing loading

Source:

toPng(filename, width, height, keepAspect) → {Number}

Renders a webview to a png file

Parameters:
Name Type Description
filename String

The filename for the png.

width Number

The width of the png, if width is < 0 and height is > 0 the image will have the same aspect ratio as the original webview, optional.

height Number

The height of the png, if height is < 0 and width is > 0 the image will have the same aspect ratio as the original webview, optional, mandatory if width is set.

keepAspect Boolean

Whether to keep the ascpect ratio, if set to true the new image will have the same aspect ratio as the original webview, width and height are taken as maximum sizes and must both be > 0, optional.

Source:
Returns:
  • Type
    Number
  • A cairo_status_t, 0 on success, -1 if an error occured

toPng64(width, height, keepAspect) → {String}

Renders a webview to a base64 encoded png

Parameters:
Name Type Description
width Number

The width of the png, if width is < 0 and height is > 0 the image will have the same aspect ratio as the original webview, optional.

height Number

The height of the png, if height is < 0 and width is > 0 the image will have the same aspect ratio as the original webview, optional, mandatory if width is set.

keepAspect Boolean

Whether to keep the ascpect ratio, if set to true the new image will have the same aspect ratio as the original webview, width and height are taken as maximum sizes and must both be > 0, optional.

Source:
Returns:
  • Type
    String
  • A base64 encoded png-String

Example
var png = tabs.current.toPng64(250, 250, true); 
tabs.current.inject(function() {
    var img = document.createElement("img");
    img.src = "data:image/png;base64," + arguments[0];
    document.body.appendChild(img);
}, png);

unblockSignal(id)

Unblocks a signal that was blocked with GObject#blockSignal

Parameters:
Name Type Description
id Number

The signal id retrieved from GObject#connect

Inherited From:
Source:

Type Definitions

loadUriCallback(wv)

Callback that will be called if the load-status changes, return true to stop the emission

Parameters:
Name Type Description
wv WebKitWebView

The webview which loaded the uri

Source: