- <webview>标签·续1
- <webview>.isWaitingForResponse()
- <webview>.stop()
- <webview>.reload()
- <webview>.reloadIgnoringCache()
- <webview>.canGoBack()
- <webview>.canGoForward()
- <webview>.canGoToOffset(offset)
- <webview>.clearHistory()
- <webview>.goBack()
- <webview>.goForward()
- <webview>.goToIndex(index)
- <webview>.goToOffset(offset)
- <webview>.isCrashed()
- <webview>.setUserAgent(userAgent)
- <webview>.getUserAgent()
- <webview>.insertCSS(css)
- <webview>.removeInsertedCSS(key)
- <webview>.executeJavaScript(code[, userGesture])
- <webview>.openDevTools()
- <webview>.closeDevTools()
- <webview>.isDevToolsOpened()
- <webview>.isDevToolsFocused()
- <webview>.inspectElement(x, y)
- <webview>.inspectSharedWorker()
- <webview>.inspectServiceWorker()
- <webview>.setAudioMuted(muted)
- <webview>.isAudioMuted()
- <webview>.isCurrentlyAudible()
- <webview>.undo()
- <webview>.redo()
- <webview>.cut()
- <webview>.copy()
- <webview>.paste()
- <webview>.pasteAndMatchStyle()
- <webview>.delete()
- <webview>.selectAll()
- <webview>.unselect()
- <webview>.replace(text)
- <webview>.replaceMisspelling(text)
- <webview>.insertText(text)
- <webview>.findInPage(text[, options])
- <webview>.stopFindInPage(action)
- <webview>.print([options])
- <webview>.printToPDF(options)
- <webview>.capturePage([rect])
- <webview>.send(channel, ...args)
- <webview>.sendInputEvent(event)
- <webview>.setZoomFactor(factor)
- <webview>.setZoomLevel(level)
- <webview>.getZoomFactor()
- <webview>.getZoomLevel()
- <webview>.setVisualZoomLevelLimits(minimumLevel, maximumLevel)
- <webview>.setLayoutZoomLevelLimits(minimumLevel, maximumLevel) Deprecated
- <webview>.showDefinitionForSelection() macOS
- <webview>.getWebContents() Deprecated
<webview>标签·续1
Returns Boolean - Whether the main frame (and not just iframes or frames within it) is still loading.
<webview>.isWaitingForResponse()
返回 Boolean - 访客页面是否正在等待页面主资源的第一响应。
<webview>.stop()
Stops any pending navigation.
<webview>.reload()
刷新访客页。
<webview>.reloadIgnoringCache()
刷新访客页并忽略缓存。
<webview>.canGoBack()
返回 Boolean - 访客页能否后退。
<webview>.canGoForward()
返回 Boolean - 访客页能否前进。
<webview>.canGoToOffset(offset)
- offset Integer
返回 Boolean - 访客页能否前进到 offset。
<webview>.clearHistory()
Clears the navigation history.
<webview>.goBack()
使访客页后退。
<webview>.goForward()
使访客页前进。
<webview>.goToIndex(index)
- index Integer
定位到指定的绝对索引。
<webview>.goToOffset(offset)
- offset Integer
定位到相对于“当前入口”的指定的偏移。
<webview>.isCrashed()
Returns Boolean - Whether the renderer process has crashed.
<webview>.setUserAgent(userAgent)
- userAgent String
覆盖访客页的用户代理。
<webview>.getUserAgent()
返回 String - 访客页的用户代理。
<webview>.insertCSS(css)
- css String
Returns Promise<String> - A promise that resolves with a key for the inserted CSS that can later be used to remove the CSS via <webview>.removeInsertedCSS(key).
Injects CSS into the current web page and returns a unique key for the inserted stylesheet.
<webview>.removeInsertedCSS(key)
- key String
Returns Promise<void> - Resolves if the removal was successful.
Removes the inserted CSS from the current web page. The stylesheet is identified by its key, which is returned from <webview>.insertCSS(css).
<webview>.executeJavaScript(code[, userGesture])
-
code String
-
userGesture Boolean (可选) - 默认为 false。
Returns Promise<any> - A promise that resolves with the result of the executed code or is rejected if the result of the code is a rejected promise.
在页面中执行 code。 如果设置了userGesture,它将在页面中创建用户手势上下文。 像 requestFullScreen 这样的需要用户操作的HTML API可以利用这个选项来实现自动化。
<webview>.openDevTools()
Opens a DevTools window for guest page.
<webview>.closeDevTools()
Closes the DevTools window of guest page.
<webview>.isDevToolsOpened()
Returns Boolean - Whether guest page has a DevTools window attached.
<webview>.isDevToolsFocused()
Returns Boolean - Whether DevTools window of guest page is focused.
<webview>.inspectElement(x, y)
-
x Integer
-
y Integer
Starts inspecting element at position (x, y) of guest page.
<webview>.inspectSharedWorker()
Opens the DevTools for the shared worker context present in the guest page.
<webview>.inspectServiceWorker()
Opens the DevTools for the service worker context present in the guest page.
<webview>.setAudioMuted(muted)
- muted Boolean
设置访客页是否静音。
<webview>.isAudioMuted()
返回 Boolean - 访客页是否被静音。
<webview>.isCurrentlyAudible()
Returns Boolean - Whether audio is currently playing.
<webview>.undo()
在页面中执行编辑命令 undo。
<webview>.redo()
在页面中执行编辑命令 redo。
<webview>.cut()
在页面中执行编辑命令 cut。
<webview>.copy()
在页面中执行编辑命令 copy。
<webview>.paste()
在页面中执行编辑命令 paste。
<webview>.pasteAndMatchStyle()
在页面中执行编辑命令 pasteAndMatchStyle。
<webview>.delete()
在页面中执行编辑命令 delete。
<webview>.selectAll()
在页面中执行编辑命令 selectAll。
<webview>.unselect()
在页面中执行编辑命令 unselect。
<webview>.replace(text)
- text String
在页面中执行编辑命令 replace。
<webview>.replaceMisspelling(text)
- text String
在页面中执行编辑命令 replaceMisspelling。
<webview>.insertText(text)
- text String
Returns Promise<void>
插入text 到焦点元素
<webview>.findInPage(text[, options])
-
text String - 要搜索的内容,必须非空。
-
options Object (optional)
-
forward Boolean (可选) -向前或向后搜索,默认为 true。
-
findNext Boolean (optional) - Whether the operation is first request or a follow up, defaults to false.
-
matchCase Boolean (optional) - Whether search should be case-sensitive, defaults to false.
-
wordStart Boolean (optional) - Whether to look only at the start of words. 默认值为 false.
-
medialCapitalAsWordStart Boolean (optional) - When combined with wordStart, accepts a match in the middle of a word if the match begins with an uppercase letter followed by a lowercase or non-letter. Accepts several other intra-word matches, defaults to false.
Returns Integer - The request id used for the request.
Starts a request to find all matches for the text in the web page. The result of the request can be obtained by subscribing to found-in-page event.
<webview>.stopFindInPage(action)
-
action String - Specifies the action to take place when ending <webview>.findInPage request.
-
clearSelection - Clear the selection.
-
keepSelection - Translate the selection into a normal selection.
-
activateSelection - Focus and click the selection node.
Stops any findInPage request for the webview with the provided action.
<webview>.print([options])
-
options Object (optional)
-
silent Boolean (optional) - Don’t ask user for print settings. 默认值为 false.
-
printBackground Boolean (optional) - Also prints the background color and image of the web page. 默认值为 false.
-
deviceName String (optional) - Set the printer device name to use. Default is ''.
Returns Promise<void>
Prints webview‘s web page. Same as webContents.print([options]).
<webview>.printToPDF(options)
-
options Object
-
marginsType Integer (optional) - Specifies the type of margins to use. Uses 0 for default margin, 1 for no margin, and 2 for minimum margin.
-
pageSize String | Size (optional) - Specify page size of the generated PDF. Can be A3, A4, A5, Legal, Letter, Tabloid or an Object containing height and width in microns.
-
printBackground Boolean (optional) - Whether to print CSS backgrounds.
-
printSelectionOnly Boolean (optional) - Whether to print selection only.
-
landscape Boolean (optional) - true for landscape, false for portrait.
Returns Promise<Uint8Array> - Resolves with the generated PDF data.
Prints webview‘s web page as PDF, Same as webContents.printToPDF(options).
<webview>.capturePage([rect])
- rect Rectangle (optional) - The area of the page to be captured.
Returns Promise<NativeImage> - Resolves with a NativeImage
Captures a snapshot of the page within rect. Omitting rect will capture the whole visible page.
<webview>.send(channel, ...args)
-
channel String
-
...args any[]
Returns Promise<void>
通过channel向渲染器进程发送异步消息,可以发送任意参数。 The renderer process can handle the message by listening to the channel event with the ipcRenderer module.
示例请进传送门: webContents.send
<webview>.sendInputEvent(event)
- event MouseInputEvent | MouseWheelInputEvent | KeyboardInputEvent
Returns Promise<void>
Sends an input event to the page.
See webContents.sendInputEvent for detailed description of event object.
<webview>.setZoomFactor(factor)
- factor Number - 缩放比例
Changes the zoom factor to the specified factor. Zoom factor is zoom percent divided by 100, so 300% = 3.0.
<webview>.setZoomLevel(level)
- level Number - 缩放等级。
更改缩放等级。 The original size is 0 and each increment above or below represents zooming 20% larger or smaller to default limits of 300% and 50% of original size, respectively. The formula for this is scale := 1.2 ^ level.
<webview>.getZoomFactor()
Returns Number - the current zoom factor.
<webview>.getZoomLevel()
Returns Number - the current zoom level.
<webview>.setVisualZoomLevelLimits(minimumLevel, maximumLevel)
-
minimumLevel Number
-
maximumLevel Number
Returns Promise<void>
设置最大和最小缩放级别。
<webview>.setLayoutZoomLevelLimits(minimumLevel, maximumLevel) Deprecated
-
minimumLevel Number
-
maximumLevel Number
Returns Promise<void>
设置最大和最小基于布局(例如非图像)的缩放级别。
Deprecated: This API is no longer supported by Chromium.
<webview>.showDefinitionForSelection() macOS
Shows pop-up dictionary that searches the selected word on the page.
<webview>.getWebContents() Deprecated
Returns WebContents - The web contents associated with this webview.
It depends on the remote module, it is therefore not available when this module is disabled.
