Chrome javascript ดักจับตอน click X ปิด browser

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: Chrome javascript ดักจับตอน click X ปิด browser

Chrome javascript ดักจับตอน click X ปิด browser

โดย jataz2 » 05/04/2019 10:51 am

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">

โค้ด: เลือกทั้งหมด

<script type="text/javascript">
        var posx;var posy;

        $(window).bind('beforeunload', function(e){ 

            posx=window.pageXOffset;
            posy=window.pageYOffset;
            
            if (posy <= 0)
            {
                doUnload();
            }
        });

        function doUnload()
        {
            Alert ("exit");
        }
 </script>
</head>
<body>

</body>
</html>

ข้างบน