<div id="test"></div> <script> window.onload = function () { window.name = (+window.name || 0) + 1; test.innerHTML = window.name; }; </script>