Skip to content

imagine10255/bear-window-launcher

Repository files navigation

Bear Window Launcher

This is a window launcher for front-end compatibility with browser issues when using window.open.

NPM npm downloads npm npm

Features

  • Supports window.open after asynchronous requests in iOS Safari.
  • Supports whether to close the old window when opening a new one
  • Provides browser detection (Safari, Firefox, IE, Wechat, Line, Facebook), default is Chrome.

Installation

yarn add bear-window-launcher

Examples

use in your page/component:

import {Launcher} from 'bear-window-launcher';

const launcher = new Launcher({
    readyUrl: '/ready_page'
});

// This is to support safari, so it must be
// Safari needs to pre-open tabs before requesting, other browsers do not need to
launcher.ready();

// async requet
const response = await fetch('/url1.json');
const json = await response.json();

launcher.open(json.data);

Check Browser

import Launcher, {
    checkIsMobile,
    checkIsAndroid,
    checkIsIOS,
    getBrowser,
    checkIsChromeBrowser,
    checkIsSafariBrowser,
    checkIsFirefoxBrowser,
    checkIsEdgeBrowser,
    checkIsLineBrowser,
    checkIsFacebookBrowser, checkIsWebview, checkIsPWA
} from 'bear-window-launcher';

Check OS

import Launcher, {
    checkIsMobile,
    checkIsAndroid,
    checkIsIOS,
} from 'bear-window-launcher';

License

MIT © imagine10255

About

This is a window launcher for front-end compatibility with browser issues when using window.open.

Topics

Resources

Stars

Watchers

Forks