Use the webview tag to actively load live content from the web over the network and embed it in your Chrome App. Your app can control the appearance of the webview and interact with the web content, initiate navigations in an embedded web page, react to error events that happen within it, and more (see Usage).
Use the webview tag to actively load live content from the web over the network and embed it in your Chrome App. Your app can control the appearance of the webview and interact with the web content, initiate navigations in an embedded web page, react to error events that happen within it, and more (see Usage). * available since Chrome 32 * https://developer.chrome.com/apps/tags/webview
(add-content-scripts content-script-list)
Adds content script injection rules to the webview. When the webview navigates to a page matching one or more rules, the associated scripts will be injected. You can programmatically add rules or update existing rules.The following example adds two rules to the webview: 'myRule' and 'anotherRule'.webview.addContentScripts([ { name: 'myRule', matches: ['http://www.foo.com/*'], css: { files: ['mystyles.css'] }, js: { files: ['jquery.js', 'myscript.js'] }, run_at: 'document_start' }, { name: 'anotherRule', matches: ['http://www.bar.com/*'], js: { code: 'document.body.style.backgroundColor = 'red';' }, run_at: 'document_end' }]); ...
// Navigates webview. webview.src = 'http://www.foo.com';You can defer addContentScripts call until you needs to inject scripts.The following example shows how to overwrite an existing rule.webview.addContentScripts([{ name: 'rule', matches: ['http://www.foo.com/*'], js: { files: ['scriptA.js'] }, run_at: 'document_start'}]);
// Do something. webview.src = 'http://www.foo.com/*'; ... // Overwrite 'rule' defined before. webview.addContentScripts([{ name: 'rule', matches: ['http://www.bar.com/*'], js: { files: ['scriptB.js'] }, run_at: 'document_end'}]);If webview has been naviagted to the origin (e.g., foo.com) and calls webview.addContentScripts to add 'myRule', you need to wait for next navigation to make the scripts injected. If you want immediate injection, executeScript will do the right thing.Rules are preserved even if the guest process crashes or is killed or even if the webview is reparented.Refer to the content scripts documentation for more details.
|content-script-list| - Details of the content scripts to add.
https://developer.chrome.com/apps/tags/webview#method-addContentScripts.
Adds content script injection rules to the webview. When the webview navigates to a page matching one or more rules, the associated scripts will be injected. You can programmatically add rules or update existing rules.The following example adds two rules to the webview: 'myRule' and 'anotherRule'.webview.addContentScripts([ { name: 'myRule', matches: ['http://www.foo.com/*'], css: { files: ['mystyles.css'] }, js: { files: ['jquery.js', 'myscript.js'] }, run_at: 'document_start' }, { name: 'anotherRule', matches: ['http://www.bar.com/*'], js: { code: 'document.body.style.backgroundColor = 'red';' }, run_at: 'document_end' }]); ... // Navigates webview. webview.src = 'http://www.foo.com';You can defer addContentScripts call until you needs to inject scripts.The following example shows how to overwrite an existing rule.webview.addContentScripts([{ name: 'rule', matches: ['http://www.foo.com/*'], js: { files: ['scriptA.js'] }, run_at: 'document_start'}]); // Do something. webview.src = 'http://www.foo.com/*'; ... // Overwrite 'rule' defined before. webview.addContentScripts([{ name: 'rule', matches: ['http://www.bar.com/*'], js: { files: ['scriptB.js'] }, run_at: 'document_end'}]);If webview has been naviagted to the origin (e.g., foo.com) and calls webview.addContentScripts to add 'myRule', you need to wait for next navigation to make the scripts injected. If you want immediate injection, executeScript will do the right thing.Rules are preserved even if the guest process crashes or is killed or even if the webview is reparented.Refer to the content scripts documentation for more details. |content-script-list| - Details of the content scripts to add. https://developer.chrome.com/apps/tags/webview#method-addContentScripts.
(back)
Navigates backward one history entry if possible. Equivalent to go(-1).
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [success] where:
|success| - Indicates whether the navigation was successful.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Navigates backward one history entry if possible. Equivalent to go(-1). This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [success] where: |success| - Indicates whether the navigation was successful. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/tags/webview#method-back.
(can-go-back)
Indicates whether or not it is possible to navigate backward through history. The state of this function is cached, and updated before each loadcommit, so the best place to call it is on loadcommit.
https://developer.chrome.com/apps/tags/webview#method-canGoBack.
Indicates whether or not it is possible to navigate backward through history. The state of this function is cached, and updated before each loadcommit, so the best place to call it is on loadcommit. https://developer.chrome.com/apps/tags/webview#method-canGoBack.
(can-go-forward)
Indicates whether or not it is possible to navigate forward through history. The state of this function is cached, and updated before each loadcommit, so the best place to call it is on loadcommit.
https://developer.chrome.com/apps/tags/webview#method-canGoForward.
Indicates whether or not it is possible to navigate forward through history. The state of this function is cached, and updated before each loadcommit, so the best place to call it is on loadcommit. https://developer.chrome.com/apps/tags/webview#method-canGoForward.
(capture-visible-region)
(capture-visible-region options)
Captures the visible region of the webview.
|options| - Details about the format and quality of an image.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [data-url] where:
|data-url| - A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/tags/webview#method-captureVisibleRegion.
Captures the visible region of the webview. |options| - Details about the format and quality of an image. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [data-url] where: |data-url| - A data URL which encodes an image of the visible area of the captured tab. May be assigned to the 'src' property of an HTML Image element for display. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/tags/webview#method-captureVisibleRegion.
(clear-data options types)
Clears browsing data for the webview partition.
|options| - Options determining which data to clear. |types| - The types of data to be cleared.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [].
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/tags/webview#method-clearData.
Clears browsing data for the webview partition. |options| - Options determining which data to clear. |types| - The types of data to be cleared. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is []. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/tags/webview#method-clearData.
(execute-script details)
Injects JavaScript code into the guest page.The following sample code uses script injection to set the guest page's background color to red:webview.executeScript({ code: 'document.body.style.backgroundColor = 'red'' });
|details| - Details of the script to run.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [result] where:
|result| - The result of the script in every injected frame.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/tags/webview#method-executeScript.
Injects JavaScript code into the guest page.The following sample code uses script injection to set the guest page's background color to red:webview.executeScript({ code: 'document.body.style.backgroundColor = 'red'' }); |details| - Details of the script to run. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [result] where: |result| - The result of the script in every injected frame. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/tags/webview#method-executeScript.
(find search-text)
(find search-text options)
Initiates a find-in-page request.
|search-text| - The string to find in the page. |options| - Options for the find request.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [results] where:
|results| - Contains all of the results of the find request. results can be omitted if it is not utilized in the callback function body; for example, if the callback is only used to discern when the find request has completed.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Initiates a find-in-page request. |search-text| - The string to find in the page. |options| - Options for the find request. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [results] where: |results| - Contains all of the results of the find request. results can be omitted if it is not utilized in the callback function body; for example, if the callback is only used to discern when the find request has completed. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/tags/webview#method-find.
(forward)
Navigates forward one history entry if possible. Equivalent to go(1).
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [success] where:
|success| - Indicates whether the navigation was successful.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/tags/webview#method-forward.
Navigates forward one history entry if possible. Equivalent to go(1). This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [success] where: |success| - Indicates whether the navigation was successful. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/tags/webview#method-forward.
(get-audio-state)
Queries audio state.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [audible] where:
|audible| - https://developer.chrome.com/apps/tags/webview#property-callback-audible.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/tags/webview#method-getAudioState.
Queries audio state. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [audible] where: |audible| - https://developer.chrome.com/apps/tags/webview#property-callback-audible. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/tags/webview#method-getAudioState.
(get-content-window)
Object reference which can be used to post messages into the guest page.
https://developer.chrome.com/apps/tags/webview#property-contentWindow.
Object reference which can be used to post messages into the guest page. https://developer.chrome.com/apps/tags/webview#property-contentWindow.
(get-context-menus)
Similar to chrome's ContextMenus API, but applies to webview instead of browser. Use the webview.contextMenus API to add items to webview's context menu. You can choose what types of objects your context menu additions apply to, such as images, hyperlinks, and pages.
https://developer.chrome.com/apps/tags/webview#property-contextMenus.
Similar to chrome's ContextMenus API, but applies to webview instead of browser. Use the webview.contextMenus API to add items to webview's context menu. You can choose what types of objects your context menu additions apply to, such as images, hyperlinks, and pages. https://developer.chrome.com/apps/tags/webview#property-contextMenus.
(get-process-id)
Returns Chrome's internal process ID for the guest web page's current process, allowing embedders to know how many guests would be affected by terminating the process. Two guests will share a process only if they belong to the same app and have the same storage partition ID. The call is synchronous and returns the embedder's cached notion of the current process ID. The process ID isn't the same as the operating system's process ID.
https://developer.chrome.com/apps/tags/webview#method-getProcessId.
Returns Chrome's internal process ID for the guest web page's current process, allowing embedders to know how many guests would be affected by terminating the process. Two guests will share a process only if they belong to the same app and have the same storage partition ID. The call is synchronous and returns the embedder's cached notion of the current process ID. The process ID isn't the same as the operating system's process ID. https://developer.chrome.com/apps/tags/webview#method-getProcessId.
(get-request)
Interface which provides access to webRequest events on the guest page.
https://developer.chrome.com/apps/tags/webview#property-request.
Interface which provides access to webRequest events on the guest page. https://developer.chrome.com/apps/tags/webview#property-request.
(get-user-agent)
Returns the user agent string used by the webview for guest page requests.
https://developer.chrome.com/apps/tags/webview#method-getUserAgent.
Returns the user agent string used by the webview for guest page requests. https://developer.chrome.com/apps/tags/webview#method-getUserAgent.
(get-zoom)
Gets the current zoom factor.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [zoom-factor] where:
|zoom-factor| - The current zoom factor.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/tags/webview#method-getZoom.
Gets the current zoom factor. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [zoom-factor] where: |zoom-factor| - The current zoom factor. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/tags/webview#method-getZoom.
(get-zoom-mode)
Gets the current zoom mode.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [zoom-mode] where:
|zoom-mode| - The webview's current zoom mode.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/tags/webview#method-getZoomMode.
Gets the current zoom mode. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [zoom-mode] where: |zoom-mode| - The webview's current zoom mode. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/tags/webview#method-getZoomMode.
(go relative-index)
Navigates to a history entry using a history index relative to the current navigation. If the requested navigation is impossible, this method has no effect.
|relative-index| - Relative history index to which the webview should be navigated. For example, a value of 2 will navigate forward 2 history entries if possible; a value of -3 will navigate backward 3 entries.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [success] where:
|success| - Indicates whether the navigation was successful.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
Navigates to a history entry using a history index relative to the current navigation. If the requested navigation is impossible, this method has no effect. |relative-index| - Relative history index to which the webview should be navigated. For example, a value of 2 will navigate forward 2 history entries if possible; a value of -3 will navigate backward 3 entries. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [success] where: |success| - Indicates whether the navigation was successful. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/tags/webview#method-go.
(insert-css details)
Injects CSS into the guest page.
|details| - Details of the CSS to insert.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [].
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/tags/webview#method-insertCSS.
Injects CSS into the guest page. |details| - Details of the CSS to insert. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is []. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/tags/webview#method-insertCSS.
(is-audio-muted)
Queries whether audio is muted.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [muted] where:
|muted| - https://developer.chrome.com/apps/tags/webview#property-callback-muted.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/tags/webview#method-isAudioMuted.
Queries whether audio is muted. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [muted] where: |muted| - https://developer.chrome.com/apps/tags/webview#property-callback-muted. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/tags/webview#method-isAudioMuted.
(is-spatial-navigation-enabled)
Queries whether spatial navigation is enabled for the webview.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [enabled] where:
|enabled| - https://developer.chrome.com/apps/tags/webview#property-callback-enabled.
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/tags/webview#method-isSpatialNavigationEnabled.
Queries whether spatial navigation is enabled for the webview. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is [enabled] where: |enabled| - https://developer.chrome.com/apps/tags/webview#property-callback-enabled. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/tags/webview#method-isSpatialNavigationEnabled.
(is-user-agent-overridden)
Indicates whether or not the webview's user agent string has been overridden by 'webviewTag.setUserAgentOverride'.
https://developer.chrome.com/apps/tags/webview#method-isUserAgentOverridden.
Indicates whether or not the webview's user agent string has been overridden by 'webviewTag.setUserAgentOverride'. https://developer.chrome.com/apps/tags/webview#method-isUserAgentOverridden.
(load-data-with-base-url data-url base-url)
(load-data-with-base-url data-url base-url virtual-url)
Loads a data URL with a specified base URL used for relative links. Optionally, a virtual URL can be provided to be shown to the user instead of the data URL.
|data-url| - The data URL to load. |base-url| - The base URL that will be used for relative links. |virtual-url| - The URL that will be displayed to the user (in the address bar).
https://developer.chrome.com/apps/tags/webview#method-loadDataWithBaseUrl.
Loads a data URL with a specified base URL used for relative links. Optionally, a virtual URL can be provided to be shown to the user instead of the data URL. |data-url| - The data URL to load. |base-url| - The base URL that will be used for relative links. |virtual-url| - The URL that will be displayed to the user (in the address bar). https://developer.chrome.com/apps/tags/webview#method-loadDataWithBaseUrl.
(print)
Prints the contents of the webview. This is equivalent to calling scripted print function from the webview itself.
https://developer.chrome.com/apps/tags/webview#method-print.
Prints the contents of the webview. This is equivalent to calling scripted print function from the webview itself. https://developer.chrome.com/apps/tags/webview#method-print.
(reload)
Reloads the current top-level page.
https://developer.chrome.com/apps/tags/webview#method-reload.
Reloads the current top-level page. https://developer.chrome.com/apps/tags/webview#method-reload.
(remove-content-scripts)
(remove-content-scripts script-name-list)
Removes content scripts from a webview.The following example removes 'myRule' which was added before.webview.removeContentScripts(['myRule']);You can remove all the rules by calling:webview.removeContentScripts();
|script-name-list| - A list of names of content scripts that will be removed. If the list is empty, all the content scripts added to the webview will be removed.
https://developer.chrome.com/apps/tags/webview#method-removeContentScripts.
Removes content scripts from a webview.The following example removes 'myRule' which was added before.webview.removeContentScripts(['myRule']);You can remove all the rules by calling:webview.removeContentScripts(); |script-name-list| - A list of names of content scripts that will be removed. If the list is empty, all the content scripts added to the webview will be removed. https://developer.chrome.com/apps/tags/webview#method-removeContentScripts.
(set-audio-muted mute)
Sets audio mute state of the webview.
|mute| - Mute audio value
https://developer.chrome.com/apps/tags/webview#method-setAudioMuted.
Sets audio mute state of the webview. |mute| - Mute audio value https://developer.chrome.com/apps/tags/webview#method-setAudioMuted.
(set-spatial-navigation-enabled enabled)
Sets spatial navigation state of the webview.
|enabled| - Spatial navigation state value.
https://developer.chrome.com/apps/tags/webview#method-setSpatialNavigationEnabled.
Sets spatial navigation state of the webview. |enabled| - Spatial navigation state value. https://developer.chrome.com/apps/tags/webview#method-setSpatialNavigationEnabled.
(set-user-agent-override user-agent)
Override the user agent string used by the webview for guest page requests.
|user-agent| - The user agent string to use.
https://developer.chrome.com/apps/tags/webview#method-setUserAgentOverride.
Override the user agent string used by the webview for guest page requests. |user-agent| - The user agent string to use. https://developer.chrome.com/apps/tags/webview#method-setUserAgentOverride.
(set-zoom zoom-factor)
Changes the zoom factor of the page. The scope and persistence of this change are determined by the webview's current zoom mode (see 'webviewTag.ZoomMode').
|zoom-factor| - The new zoom factor.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [].
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/tags/webview#method-setZoom.
Changes the zoom factor of the page. The scope and persistence of this change are determined by the webview's current zoom mode (see 'webviewTag.ZoomMode'). |zoom-factor| - The new zoom factor. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is []. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/tags/webview#method-setZoom.
(set-zoom-mode zoom-mode)
Sets the zoom mode of the webview.
|zoom-mode| - Defines how zooming is handled in the webview.
This function returns a core.async channel of type promise-chan
which eventually receives a result value.
Signature of the result value put on the channel is [].
In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error.
https://developer.chrome.com/apps/tags/webview#method-setZoomMode.
Sets the zoom mode of the webview. |zoom-mode| - Defines how zooming is handled in the webview. This function returns a core.async channel of type `promise-chan` which eventually receives a result value. Signature of the result value put on the channel is []. In case of an error the channel closes without receiving any value and relevant error object can be obtained via chromex.error/get-last-error. https://developer.chrome.com/apps/tags/webview#method-setZoomMode.
(stop)
Stops loading the current webview navigation if in progress.
Stops loading the current webview navigation if in progress. https://developer.chrome.com/apps/tags/webview#method-stop.
(stop-finding)
(stop-finding action)
Ends the current find session (clearing all highlighting) and cancels all find requests in progress.
|action| - Determines what to do with the active match after the find session has ended. clear will clear the highlighting over the active match; keep will keep the active match highlighted; activate will keep the active match highlighted and simulate a user click on that match. The default action is keep.
https://developer.chrome.com/apps/tags/webview#method-stopFinding.
Ends the current find session (clearing all highlighting) and cancels all find requests in progress. |action| - Determines what to do with the active match after the find session has ended. clear will clear the highlighting over the active match; keep will keep the active match highlighted; activate will keep the active match highlighted and simulate a user click on that match. The default action is keep. https://developer.chrome.com/apps/tags/webview#method-stopFinding.
(tap-all-events chan)
Taps all valid non-deprecated events in chromex.app.webview-tag namespace.
Taps all valid non-deprecated events in chromex.app.webview-tag namespace.
(terminate)
Forcibly kills the guest web page's renderer process. This may affect multiple webview tags in the current app if they share the same process, but it will not affect webview tags in other apps.
https://developer.chrome.com/apps/tags/webview#method-terminate.
Forcibly kills the guest web page's renderer process. This may affect multiple webview tags in the current app if they share the same process, but it will not affect webview tags in other apps. https://developer.chrome.com/apps/tags/webview#method-terminate.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close