Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

navigator.sendbeacon

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

navigator.sendbeacon - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

example/index.html

2

package.json
{
"name": "navigator.sendbeacon",
"version": "0.0.6",
"version": "0.0.7",
"description": "Polyfill for navigator.sendBeacon()",

@@ -5,0 +5,0 @@ "main": "sendbeacon.js",

@@ -9,2 +9,4 @@ # Navigator.sendBeacon polyfill

Using NPM:
```bash

@@ -14,2 +16,8 @@ npm install navigator.sendbeacon

Using JavaScript source:
```html
<script src="sendbeacon.js"></script>
```
# Usage

@@ -16,0 +24,0 @@

@@ -1,5 +0,8 @@

(function(root) {
;(function(root) {
'use strict';
function sendBeacon(url, data) {
var isSupported = (('navigator' in root) &&
('sendBeacon' in root.navigator));
var sendBeacon = function (url, data) {
var xhr = ('XMLHttpRequest' in window) ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');

@@ -12,3 +15,3 @@ xhr.open('POST', url, false);

xhr.responseType = 'text/plain';
} else if (Object.prototype.toString.call(data) === '[object Blob]') {
} else if (({}).toString.call(data) === '[object Blob]') {
if (data.type) {

@@ -19,6 +22,12 @@ xhr.setRequestHeader('Content-Type', data.type);

xhr.send(data);
try {
xhr.send(data);
} catch (error) {}
return true;
}
if (isSupported) {
sendBeacon = navigator.sendBeacon;
}
if (typeof exports !== 'undefined') {

@@ -33,5 +42,5 @@ if (typeof module !== 'undefined' && module.exports) {

});
} else if ('navigator' in root && !('sendBeacon' in root.navigator)) {
} else if (!isSupported) {
root.navigator.sendBeacon = sendBeacon;
}
})(this);
})(window || this);
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc