biased-opener

2019-02-13 admin

biased-opener是什么

什么是biased-opener,Cross-platform, opens a URL with one of the browsers passed as parameter (if available in the system), preferably default browser of the user

biased-opener使用教程帮助文档

biased-opener

Build Status

Get it on npm

This module tries to open the provided URL in some of the user-supplied browsers available on the machine. It prefers the default browser of the user, otherwise it tries all other browsers in the order in which they were passed.

If no conforming browsers found, it doesn’t launch anything, just calls the callback with an error.

Tested on Windows 7 64-bit, Windows XP 32-bit, Ubuntu 14.04 64-bit, Mac OS X 10.10 (en-US locale).

It requires nodejs and npm. If you don’t have node, grab it at nodejs.org. Node installer bundles npm (node package manager)

Rationale

Certain applications require certain webkit-only features (for instance, Node Inspector). For that apps, it makes sense to only open a URL in a webkit browser, otherwise tell the user about the error instead of opening the URL in unsupported browser.

Usage as a nodejs module

$ npm install biased-opener
var biasedOpener = require('biased-opener');

var url = "http://example.org";
var cfg = {
  verbose: true,
  preferredBrowsers: ['chrome', 'opera'] // comma-delimited string "chrome, opera" is also accepted
};
// if `cfg` is not passed, it defaults to `{ verbose: false, preferredBrowsers: ['chrome'] }`

biasedOpener(url, cfg, function(err, okMsg, instance) {
    if (err) {
        // didn't find any matching browser, or there was some failure while launching it
    }
    if (instance) {
        // control the instance if you need it
        // see https://github.com/benderjs/browser-launcher2#instance
    }
});

Usage from command line

$ npm install -g biased-opener
$ biased-opener -h                             # to see all the options
$ biased-opener --verbose --browsers 'chrome, opera' 'http://example.org'

If --browsers is not passed, it defaults to chrome.

Recognized browsers

  • chrome
  • chromium
  • opera
  • firefox
  • safari
  • ie

Linux support

This module was only tested on Ubuntu. Compatibility reports and fixes for other distros are more than welcome! Use GitHub issues or email: (jakub.g.opensource) (gmail)

License

MIT © Jakub Gieryluk

Related projects

  • browser-launcher2 (cross-platform)
  •          [opener](https://github.com/domenic/opener) (cross-platform)
    
    

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-53643.html

文章标题:biased-opener

回到顶部