hs.webview:reload(true)
and by crafting the url for hs.webview:url({...})
as a table -- see the appropriate help entries for more information.hs.webview:asHSDrawing() -> hs.drawing object
hs.drawing
have been added to the hs.webview
module itself. If you believe that a useful method has been overlooked, please submit an issue.hs.webview:asHSWindow() -> hs.window object
hs.webview:setLevel(theLevel) -> drawingObject
theLevel
- the level specified as a number, which can be obtained from hs.drawing.windowLevels
.hs.drawing.windowLevels
hs.webview.certificateOIDs[]
hs.webview.windowMasks[]
hs.webview:titleVisibility([state]) -> webviewObject | string
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Function | | Description | Get or set whether or not the title text appears in the webview window. | | Parameters |state
- an optional string containing the text "visible" or "hidden", specifying whether or not the webview's title text appears when webview's window style includes "titled".hs.webview.new(rect, [preferencesTable], [userContentController]) -> webviewObject
rect
- a rectangle specifying where the webviewObject should be displayed.preferencesTable
- an optional table which can include one of more of the following keys:javaEnabled
- java is enabled (default false)javaScriptEnabled
- JavaScript is enabled (default true)javaScriptCanOpenWindowsAutomatically
- can JavaScript open windows without user intervention (default true)minimumFontSize
- minimum font size (default 0.0)plugInsEnabled
- plug-ins are enabled (default false)developerExtrasEnabled
- include "Inspect Element" in the context menusuppressesIncrementalRendering
- suppresses content rendering until fully loaded into memory (default false)applicationName
- a string specifying an application name to be listed at the end of the browser's USER-AGENT header. Note that this is only appended to the default user agent string; if you set a custom one with hs.webview:userAgent, this value is ignored.allowsAirPlay
- a boolean specifying whether media playback within the webview can play through AirPlay devices.datastore
- an hs.webview.datastore
object specifying where website data such as cookies, cacheable content, etc. is to be stored.privateBrowsing
- a boolean (default false) specifying that the datastore should be set to a new, empty and non-persistent datastore. Note that this will override the datastore
key if both are specified and this is set to true.userContentController
- an optional hs.webview.usercontent
object to provide script injection and JavaScript messaging with Hammerspoon from the webview.hs.webview:url
method before showing the webview object.hs.webview.newBrowser(rect, [preferencesTable], [userContentController]) -> webviewObject
rect
- a rectangle specifying where the webviewObject should be displayed.preferencesTable
- an optional table which specifies special settings for the webview object.userContentController
- an optional hs.webview.usercontent
object to provide script injection and JavaScript messaging with Hammerspoon from the webview.hs.webview.new(...):allowTextEntry(true):allowGestures(true):windowStyle(15)
, which specifies a webview with a title bar, title bar buttons (zoom, close, minimize), and allows form entry and gesture support for previous and next pages.hs.webview:allowGestures([value]) -> webviewObject | current value
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Get or set whether or not the webview will respond to gestures from a trackpad or magic mouse. Default is false. | | Parameters |hs.webview:allowMagnificationGestures
and hs.webview:allowNavigationGestures
.hs.webview:allowMagnificationGestures([value]) -> webviewObject | current value
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Get or set whether or not the webview will respond to magnification gestures from a trackpad or magic mouse. Default is false. | | Parameters |value
- an optional boolean value indicating whether or not the webview should respond to magnification gestures.hs.webview:allowNavigationGestures([value]) -> webviewObject | current value
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Get or set whether or not the webview will respond to the navigation gestures from a trackpad or magic mouse. Default is false. | | Parameters |value
- an optional boolean value indicating whether or not the webview should respond to navigation gestures.hs.webview:allowNewWindows([value]) -> webviewObject | current value
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Get or set whether or not the webview allows new windows to be opened from it by any method. Defaults to true. | | Parameters |value
- an optional boolean value indicating whether or not the webview should allow new windows to be opened from it.hs.webview:allowTextEntry([value]) -> webviewObject | current value
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Get or set whether or not the webview can accept keyboard for web form entry. Defaults to false. | | Parameters |value
- an optional boolean value which sets whether or not the webview will accept keyboard input.hs.webview:alpha([alpha]) -> webviewObject | currentValue
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Get or set the alpha level of the window containing the hs.webview object. | | Parameters |alpha
- an optional number between 0.0 and 1.0 specifying the new alpha level for the webview.hs.webview:attachedToolbar([toolbar]) -> webviewObject | currentValue
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Get or attach/detach a toolbar to/from the webview. | | Parameters |toolbar
- if an hs.webview.toolbar
object is specified, it will be attached to the webview. If an explicit nil is specified, the current toolbar will be removed from the webview.hs.webview.toolbar.attachToolbar
function.hs.webview:behavior([behavior]) -> webviewObject | currentValue
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Get or set the window behavior settings for the webview object. | | Parameters |behavior
- an optional number representing the desired window behaviors for the webview object.hs.drawing.windowBehaviors
for more information.hs.webview:behaviorAsLabels(behaviorTable) -> webviewObject | currentValue
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Get or set the window behavior settings for the webview object using labels defined in hs.drawing.windowBehaviors
. | | Parameters |hs.drawing.windowBehaviors
for more information.hs.webview:bringToFront([aboveEverything]) -> webviewObject
aboveEverything
- An optional boolean value that controls how far to the front the webview should be placed. True to place the webview on top of all windows (including the dock and menubar and fullscreen windows), false to place the webview above normal windows, but below the dock, menubar and fullscreen windows. Defaults to false.hs.webview:certificateChain() -> table | nil
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Returns the certificate chain for the most recently committed navigation of the webview. | | Parameters |commonName
- the common name for the certificate; most commonly this will be a string matching the server portion of the URL request or other descriptor of the certificate's purpose.values
- a table containing key-value pairs describing the certificate. The keys will be certificate OIDs. Common OIDs and their meaning can be found in hs.webview.certificateOIDs. The value for each key will be a table with the following keys:label
- a description or label for the entrylocalized label
- a localized version of label
type
- a description of the data type for this valuevalue
- the valuehs.webview:children() -> array
hs.webview:closeOnEscape([flag]) -> webviewObject | current value
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | If the webview is closable, this will get or set whether or not the Escape key is allowed to close the webview window. | | Parameters |flag
- an optional boolean value which indicates whether a webview, when it's style includes Closable (see hs.webview:windowStyle
), should allow the Escape key to be a shortcut for closing the webview window. Defaults to false.hs.webview:darkMode([state]) -> bool
hs.webview
window should display in dark mode.state
- an optional boolean which will set whether or not the hs.webview
window should display in dark mode.true
if dark mode is enabled otherwise false
.hs.webview:delete([propagate], [fadeOutTime]) -> none
propagate
- an optional boolean, default false, which indicates whether or not the child windows of this webview should also be deleted.fadeOutTime
- an optional number of seconds over which to fade out the webview object. Defaults to zero.hs.webview:deleteOnClose([value]) -> webviewObject | current value
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Get or set whether or not the webview should delete itself when its window is closed. | | Parameters |value
- an optional boolean value which sets whether or not the webview will delete itself when its window is closed by any method. Defaults to false for a window created with hs.webview.new
and true for any webview windows created by the main webview (user selects "Open Link in New Window", etc.)hs.webview.windowStyle
).hs.webview:estimatedProgress() -> number
hs.webview:evaluateJavaScript(script, [callback]) -> webviewObject
script
- the JavaScript to execute within the context of the current webview's displaycallback
- an optional function which should accept two parameters as the result of the executed JavaScript. The function parameters are as follows:result
- the result of the executed JavaScript code or nil if there was no result or an error occurred.error
- an NSError table describing any error that occurred during the JavaScript execution or nil if no error occurred.hs.webview:examineInvalidCertificates([flag]) -> webviewObject | current value
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Get or set whether or not invalid SSL server certificates that are approved by the ssl callback function are accepted as valid for browsing with the webview. | | Parameters |flag
- an optional boolean, default false, specifying whether or not an invalid SSL server certificate should be accepted if it is approved by the ssl callback function.hs.webview:frame([rect]) -> webviewObject | currentValue
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Get or set the frame of the webview window. | | Parameters |x
and y
) and the new size (keys h
and w
). The table may be crafted by any method which includes these keys, including the use of an hs.geometry
object.hs.webview:goBack() -> webviewObject
hs.webview:goForward() -> webviewObject
hs.webview:hide([fadeOutTime]) -> webviewObject
fadeOutTime
- An optional number of seconds over which to fade out the webview. Defaults to zerohs.webview:historyList() -> historyTable
current
which is equal to the index corresponding to the currently visible entry. Each array element will be a table with the following keys:URL
- the URL of the web pageinitialURL
- the URL of the initial request that led to this itemtitle
- the web page titlehs.webview:hswindow() -> hs.window object
hs.webview.windowStyle
)hs.webview.windowStyle
)hs.webview.windowStyle
)hs.webview.windowStyle
)hs.webview:html(html,[baseURL]) -> webviewObject, navigationIdentifier
html
- the html to be rendered in the webviewbaseURL
- an optional Base URL to use as the starting point for any relative links within the provided html.hs.webview:isOnlySecureContent() -> bool
hs.webview:isVisible() -> boolean
true
if the webview window is visible, otherwise false
hs.webview:level([theLevel]) -> drawingObject | currentValue
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Get or set the window level | | Parameters |theLevel
- an optional parameter specifying the desired level as an integer, which can be obtained from hs.drawing.windowLevels
.hs.drawing.windowLevels
hs.webview:loading() -> boolean
hs.webview:magnification([value]) -> webviewObject | current value
| | -----------------------------------------------------|---------------------------------------------------------------------------------------------------------| | Type | Method | | Description | Get or set the webviews current magnification level. Default is 1.0. | | Parameters |value
- an optional number specifying the webviews magnification level.hs.webview:navigationCallback(fn) -> webviewObject
fn
- the function to be called when the navigation status of a webview cahnges. To disable the callback function, explicitly specify nil. The function should expect 3 or 4 arguments and may optionally return 1. The function arguments are defined as follows:action
- a string indicating the webview's current status. It will be one of the following:didStartProvisionalNavigation
- a request or action to change the contents of the main frame has occurreddidReceiveServerRedirectForProvisionalNavigation
- a server redirect was received for the main framedidCommitNavigation
- content has started arriving for the main framedidFinishNavigation
- the webview's main frame has completed loading.didFailNavigation
- an error has occurred after content started arrivingdidFailProvisionalNavigation
- an error has occurred as or before content has started arrivingwebView
- the webview object the navigation is occurring for.