SingleTab prevents users from opening multiple tabs.
SingleTab prevents users from opening multiple tabs in modern browsers.
If you need to prevent users from opening your page/web application in mutliple windows or tabs, this is solution for you.
Just include SsingleTab into footer of every page which cannot be opened mutliple times and when SingleTab fires your function, display alert or redirect user.
<script src="singletab.js"></script>
singleTab.init({ /* parameters */ });
singleTab.start();
multifire - function to fire every time when “check” is called and detects page loaded in multiple tabs (warning: multifire fires approx. every interval
ms when tabs are detected)
<script>
singleTab.init({
fire: function() {
document.getElementById('result').innerHTML='Hey! Close it!';
},
storage: "name",
interval: 500
});
singleTab.start();
</script>
This is just a quick project - code was not tested in older browsers and you shouldn’t rely on it. It might be better to implement some AJAX and Database solution. If user disables Javascript/uses older browser or IE, they can easily bypass SingleTab.