Class page

Web process counterpart to the webview widget
This module is only available from web process Lua states.

The page is the web process counterpart to the webview widget; for each webview widget created on the UI process, a corresponding page instance is created in a web process.


page:eval_js (script, options)

Synchronously run a string of JavaScript code in the context of the webview. The JavaScript will run even if the enable_javascript property of the webview is false, as it is run within a separate JavaScript script world.

If the options parameter is provided, only the source key is recognized; if provided, it should be a string to use in error messages.


  • script
    Type: string
    The JavaScript string to evaluate.
  • options
    Type: table
    Default: {}
    Additional arguments.



Type: string
The current active URI of the page.


Type: dom_document
The dom_document currently loaded in the page.

Type: integer
Unique ID number associated with the web page.

A page and webview widget pair will always have the same ID; this is useful for coordinating Lua accross processes.



Emitted when the DOM document of the page has finished loading.


Emitted before every HTTP request is sent. By connecting to this signal one can redirect the request to a different URI, or block the request entirely. It is also possible to modify the HTTP headers sent with the request.

Redirecting a request to a different URI

To redirect a request to a different URI, return the new URI from your signal handler.

page:add_signal("send-request", function ()
    return "" -- Redirect everything to localhost

Blocking a request

To block a request, return false.

page:add_signal("send-request", function (_, uri)
    if uri:match("^http:") then
        return false -- Block all http:// requests

Modifying HTTP headers

To modify the HTTP headers sent with the request, modify the headers table.

page:add_signal("send-request", function (_, _, headers)
    headers.Referer = nil -- Don't send Referer header


  • page
    Type: page
    The page.
  • uri
    Type: string
    The URI of the request.
  • headers
    Type: table
    The HTTP headers of the request.

Return Values

  • string or false
    A redirect URI, or false to block the request.