shubanker / Tabs-Counter

Track number of tabs user has opened of your website.

Home Page:https://output.jsbin.com/qodejup

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tab Counter

Track the number of Tabs a user has currently opened of your website.

Getting Started

Include TabCounter.js in your page.

console.log(tabCount.tabsCount());

you can also set tabCount change events by passing callback function to tabCount.onTabChange which will be triggered each time number of tab changes, check out this example, you can also see it working here, tabCount.onTabChange also has a second optional parameter which accepts a boolean value to execute callBack immediatly, default is set to false.

Configuration:

Tabcounter runs a TimeInterval internally to track change in number of tabs, default interval is set to 2000ms (2 seconds) which can configured by function tabCount.updateActiveInterval.

Limitations:

Browses tend to throttle TimeIntervals of inactive tabs especially if timer is less than 1000ms(1s), espically for mobile browsers, thus the counter may fail to give precious count, workaround on this is WebWorkers, for more precious count include a WebWorker library such as this before loading Tab counter example.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

About

Track number of tabs user has opened of your website.

https://output.jsbin.com/qodejup

License:MIT License


Languages

Language:JavaScript 54.9%Language:TypeScript 45.1%