# Luakit Documentation / Modules / webview

# Module `webview`

Webview widget wrapper

The webview module wraps the webview widget provided by luakit, adding several convenience APIs and providing basic functionality.

## Functions

### webview.methods.scroll (view, w, new)

Scroll the current webview by a given amount.

#### Parameters

- view
  Type: widget
  The webview widget to scroll.
- w
  Type: table
  The window class table for the window containing `view`.
- new
  Type: table
  Table of scroll information.

### webview.new (opts)

Create a new webview instance.

#### Parameters

- opts
  Type: table
  Table of options. Currently only `private` is recognized as a key.

#### Return Values

- table
  The newly-created webview widget.

### webview.window (view)

Wrapper for `window.ancestor`.

#### Parameters

- view
  Type: widget
  The webview whose ancestor to find.

#### Return Values

- table or nil
  The window class table for the window that contains `view`, or `nil` if `view` is not contained within a window.

### webview.modify_load_block (view, name, enable)

Add/remove a load block on the given webview. If a block is enabled on a webview, load requests will be suspended until the block is removed. This is useful for pausing network operations while a module is initializing.

#### Parameters

- view
  Type: widget
  The view on which to add/remove the load block.
- name
  Type: string
  The name of the block to add/remove.
- enable
  Type: boolean
  Whether the block should be enabled.

### webview.has_load_block (view)

Check whether the given webview has a load block.

#### Parameters

- view
  Type: widget
  The webview.

#### Return Values

- boolean
  `true` if the given webview has a load block.

### webview.set_location (view, arg)

Set the location of the webview. This method will respect any load blocks in place (see `modify_load_block`).

#### Parameters

- view
  Type: widget
  The view whose location to modify.
- arg
  Type: table
  The new location. Can be a URI, a JavaScript URI, or a table with `session_state` and `uri` keys.

## Properties

### webview.methods

Type: {[string]=function}
Read-write
These methods are present when you index a window instance and no window method is found in `window.methods`. The window then checks if there is an active webview and calls the following methods with the given view instance as the first argument. All methods must take `view` & `w` as the first two arguments.

## Attribution

#### Copyright

- 2017 Aidan Holm
- 2012 Mason Larobina