new·Earn with mozg — 20% of every monthSend somebody here and take a fifth of every plan payment they make, for as long as they keep paying — not a bounty on the first invoice. Your handle is the link, the window is thirty days, and the commission lands on your balance the second they pay. Free to join: if you have signed in, you already have the link. mozg.sh/earnall news →
mozg.beta
Sign in

Electron · API · all subjects

webcontents: navigation & history

16 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

win.reload()

Reloads the current page. Same as webContents.reload().

WebPreferences focusOnNavigation property

The `focusOnNavigation` boolean property determines whether to focus the WebContents when navigating. Default is `true`.

webview navigation and history methods

webview supports: getURL() returns the URL of guest page, getTitle() returns title, isLoading() returns whether resources are loading, isLoadingMainFrame() returns whether main frame is loading, isWaitingForResponse() returns whether waiting for first response, stop() stops pending navigation, reload() reloads page, reloadIgnoringCache() reloads ignoring cache, canGoBack() returns whether can go back, canGoForward() returns whether can go forward, canGoToOffset(offset) returns whether can go to offset, clearHistory() clears navigation history, goBack() goes back, goForward() goes forward, goToIndex(index) navigates to absolute index, goToOffset(offset) navigates by offset from current entry.

webview load-commit event

load-commit event fires when load has committed, including navigation within current document and subframe document-level loads, but not asynchronous resource loads. Returns: url (string), isMainFrame (boolean).

webview did-finish-load event

did-finish-load event fires when navigation is done, tab spinner stops spinning, and onload event is dispatched.

webview did-fail-load event

did-fail-load event fires when load failed or was cancelled, e.g. window.stop() was invoked. Returns: errorCode (Integer), errorDescription (string), validatedURL (string), isMainFrame (boolean).

webview did-frame-finish-load event

did-frame-finish-load event fires when a frame has done navigation. Returns: isMainFrame (boolean).

webview will-navigate event

will-navigate event emits when user or page wants to start navigation, such as when window.location changes or user clicks link. Does not emit when navigation started programmatically with loadURL or back, or during in-page navigation like anchor links or window.location.hash. preventDefault() has no effect. Returns: url (string).

webview will-frame-navigate event

will-frame-navigate event emits when user or page wants to start navigation in webview or frames within. Does not emit when navigation started programmatically or during in-page navigation. preventDefault() has no effect. Returns: url (string), isMainFrame (boolean), frameProcessId (Integer), frameRoutingId (Integer).

webview did-start-navigation event

did-start-navigation event emits when any frame starts navigating. Returns: url (string), isInPlace (boolean, true for in-page navigations), isMainFrame (boolean), frameProcessId (Integer), frameRoutingId (Integer).

webview did-redirect-navigation event

did-redirect-navigation event emits after server side redirect during navigation, e.g. 302 redirect. Returns: url (string), isInPlace (boolean), isMainFrame (boolean), frameProcessId (Integer), frameRoutingId (Integer).

webview did-navigate event

did-navigate event emits when navigation is done. Not emitted for in-page navigations like anchor links or window.location.hash. Returns: url (string).

webview did-frame-navigate event

did-frame-navigate event emits when any frame navigation is done. Not emitted for in-page navigations. Returns: url (string), httpResponseCode (Integer, -1 for non-HTTP navigations), httpStatusText (string, empty for non-HTTP navigations), isMainFrame (boolean), frameProcessId (Integer), frameRoutingId (Integer).

webview did-navigate-in-page event

did-navigate-in-page event emits when in-page navigation happened, such as anchor links or DOM hashchange event triggered. Page URL changes but no navigation outside page occurs. Returns: isMainFrame (boolean), url (string).

webview update-target-url event

update-target-url event emits when mouse moves over link or keyboard moves focus to link. Returns: url (string).

webview.loadURL parameters

loadURL(url[, options]) loads a URL in the webview. Parameters: url (required, must contain protocol prefix like http:// or file://), options (optional object with httpReferrer (string or Referrer), userAgent (string), extraHeaders (string with headers separated by newline), postData (array of UploadRawData or UploadFile), baseURLForDataURL (string for data URLs needing other files)). Returns Promise<void> that resolves when page finishes loading or rejects if page fails to load.

Give your agent this brain