npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

check-brower

v1.3.0

Published

check brower tool

Downloads

6

Readme

check-brower

GitHub license GitHub version GitHub stars GitHub forks GitHub issues npm download

checkbrower是一个检测当前环境的是PC端还是无线端,浏览器类型和版本号的插件

使用

1.1 本地引入封装的js文件

checkbrower.js是必须要引入的

第一步:获取组件方式:git clone https://github.com/saucxs/checkbrower.git

第二步:clone后,在需要加水印的相关页面引入水印文件"checkbrower.js":

<script src="./checkbrower.js"></script>

第三步:调用browserCheck方法:

//获取浏览器检测对象currentBrowser,包含browser,version,mobile,这三个参数
//brower代表的是浏览器的类型:值为Chrome,Firefox,IE,Safari等;version代表的是浏览器的版本,值为数字;mobile代表的是是否是无线端(手机端)浏览器,值为true,false
var currentBrowser = browserCheck();
 if (currentBrowser.mobile) {
      // 显示“暂不支持移动端访问,请用PC访问”
    } else if( (currentBrowser.browser == "Chrome" && currentBrowser.version < 68) ||
      (currentBrowser.browser == "Firefox" && currentBrowser.version < 60) ||
      (currentBrowser.browser == "IE" && currentBrowser.version < 10) ||
      (currentBrowser.browser == "Safari" && currentBrowser.version < 11)
    ){
      // 显示“当前浏览器的类型(currentBrowser.browser)和版本(currentBrowser.version)”
    } else{
      //支持的浏览器类型,正常显示
    }

1.2 npm包引入

npm i --save check-brower

在需要的页面引入

 // 引入
import checkBrower from 'check-brower'

// 调用方法
//获取浏览器检测对象currentBrowser,包含browser,version,mobile,这三个参数
//brower代表的是浏览器的类型:值为Chrome,Firefox,IE,Safari等;version代表的是浏览器的版本,值为数字;mobile代表的是是否是无线端(手机端)浏览器,值为true,false
 let currentBrowser = (new checkBrower()).init();
 if (currentBrowser.mobile) {
      // 显示“暂不支持移动端访问,请用PC访问”
      console.log('暂不支持移动端访问,请用PC访问')
    } else if( (currentBrowser.browser == "Chrome" && currentBrowser.version < 68) ||
      (currentBrowser.browser == "Firefox" && currentBrowser.version < 60) ||
      (currentBrowser.browser == "IE" && currentBrowser.version < 10) ||
      (currentBrowser.browser == "Safari" && currentBrowser.version < 11)
    ){
      // 显示“当前浏览器的类型(currentBrowser.browser)和版本(currentBrowser.version)”
      console.log('当前浏览器的类型'+ currentBrowser.browser + ')和版本('+ currentBrowser.version + ')')
    } else{
      //支持的浏览器类型,正常显示
      console.log('支持的浏览器类型,正常显示')
 }

使用栗子

查看地址:https://www.mwcxs.top/static/testTool/checkBrower/index.html

说明:

1、兼容到谷歌浏览器67及以上的,火狐浏览器59及以上,IE浏览器9及以上,Safari浏览器10及以上;

2、除了上述的范围的都会出现更换浏览器的提示

3、IE8的截图

image

4、android手机端截图

image