-->

Contoh Script Mendeteksi Jumlah Tab Yang Terbuka Di Browser

 <!DOCTYPE html>

<html>

<head>

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<title></title>

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<meta name="robots" content="noindex, nofollow">

<meta name="googlebot" content="noindex, nofollow">

<meta name="viewport" content="width=device-width, initial-scale=1">

<script>







(function() {

    var stor = window.localStorage;

    window.addEventListener("load", function(e) {

        var openTabs = stor.getItem("openTabs");

        if (openTabs) {

            openTabs++;

            stor.setItem("openTabs", openTabs)

        } else {

            stor.setItem("openTabs", 1)

        }

        render();

    })

    window.addEventListener("unload", function(e) {

        e.preventDefault();

        var openTabs = stor.getItem("openTabs");

        if (openTabs) {

            openTabs--;

            stor.setItem("openTabs", openTabs)

        }

        e.returnValue = '';

    });

    window.addEventListener('storage', function(e) {

        render();

    })


    function render() {

        var openTabs = stor.getItem("openTabs");


if( openTabs >= 2 ){







        var tabnum = document.getElementById("tabnum");

        var dname = document.getElementById("dname");

        tabnum.textContent = openTabs;

        dname.textContent = window.location.host












}



    }

}());



</script>

</head>

<body>

<div style="width:100%;height:100%;text-align:center;">

    <h1 >You Have<h1>

        <h1 id="tabnum">0</h1>

    <h1>Tab(s) of <span id="dname"></span> Open</h1>

</div>

</body>

</html>