Search completed in 1.32 seconds.
12 results for "sendBeacon":
Navigator.sendBeacon() - Web APIs
WebAPINavigatorsendBeacon
the navigator.sendbeacon() method asynchronously sends a small amount of data over http to a web server.
... syntax navigator.sendbeacon(url, data); parameters url the url that will receive the data.
... return values the sendbeacon() method returns true if the user agent successfully queued the data for transfer.
...And 5 more matches
Using the Beacon API - Web APIs
WebAPIBeacon APIUsing the Beacon API
navigator.sendbeacon() the beacon api's navigator.sendbeacon() method sends a beacon request to the server in the global browsing context.
...the handler calls sendbeacon() with the current url.
... window.onload = window.onunload = function analytics(event) { if (!navigator.sendbeacon) return; var url = "https://example.com/analytics"; // create the data to send var data = "state=" + event.type + "&location=" + location.href; // send the beacon var status = navigator.sendbeacon(url, data); // log the data and result console.log("sendbeacon: url = ", url, "; data = ", data, "; status = ", status); }; the following example creates a submit handler and when that event is fired, the handler calls sendbeacon().
...And 4 more matches
Synchronous and asynchronous requests - Web APIs
WebAPIXMLHttpRequestSynchronous and Asynchronous Requests
when fetch with keepalive isn't available, you can consider using the navigator.sendbeacon() api, which can support these use cases while typically delivering a good ux.
...:( client.setrequestheader("content-type", "text/plain;charset=utf-8"); client.send(analyticsdata); } using the sendbeacon() method, the data will be transmitted asynchronously to the web server when the user agent has had an opportunity to do so, without delaying the unload or affecting the performance of the next navigation.
... the following example shows a theoretical analytics code pattern that submits data to a server by using the sendbeacon() method.
... window.addeventlistener('unload', logdata, false); function logdata() { navigator.sendbeacon("/log", analyticsdata); } ...
Beacon API - Web APIs
WebAPIBeacon API
global context the beacon api's navigator.sendbeacon() method is used to send a beacon of data to the server in the global browsing context.
... worker context the beacon api's navigator.sendbeacon() method is used to send a beacon of data to the server from the worker global scope.
PerformanceEventTiming - Web APIs
WebAPIPerformanceEventTiming
function sendtoanalytics(data) { const body = json.stringify(data); // use `navigator.sendbeacon()` if available, falling back to `fetch()`.
... (navigator.sendbeacon && navigator.sendbeacon('/analytics', body)) || fetch('/analytics', {body, method: 'post', keepalive: true}); } // use a try/catch instead of feature detecting `first-input` // support, since some browsers throw when using the new `type` option.
CSP: connect-src - HTTP
WebHTTPHeadersContent-Security-Policyconnect-src
the apis that are restricted are: <a> ping, fetch, xmlhttprequest, websocket, eventsource, and navigator.sendbeacon().
...en this csp header: content-security-policy: connect-src https://example.com/ the following connections are blocked and won't load: <a ping="https://not-example.com"> <script> var xhr = new xmlhttprequest(); xhr.open('get', 'https://not-example.com/'); xhr.send(); var ws = new websocket("https://not-example.com/"); var es = new eventsource("https://not-example.com/"); navigator.sendbeacon("https://not-example.com/", { ...
Index - Web APIs
WebAPIIndex
2657 navigator.sendbeacon() api, beacon, method, navigator, networking, reference, web performance, sendbeacon the navigator.sendbeacon() method can be used to asynchronously transfer a small amount of data over http to a web server.
Navigator - Web APIs
WebAPINavigator
navigator.sendbeacon() used to asynchronously transfer a small amount of data using http from the user agent to a web server.
RequestDestination - Web APIs
WebAPIRequestDestination
navigator.sendbeacon(), eventsource, <a ping>, <area ping>, fetch(), xmlhttprequest, websocket, cache and more.
WindowOrWorkerGlobalScope.fetch() - Web APIs
WebAPIWindowOrWorkerGlobalScopefetch
fetch with the keepalive flag is a replacement for the navigator.sendbeacon() api.
<a> - SVG: Scalable Vector Graphics
WebSVGElementa
for a more widely-supported feature addressing the same use cases, see navigator.sendbeacon().
Mixed content - Web security
WebSecurityMixed content
<object> (data attribute) navigator.sendbeacon (url attribute) other resource types like web fonts and workers may be considered active mixed content, as they are in chrome.