jaideejung007 โพสต์ 2013-10-6 02:03:27

โค้ด Javascript สำหรับปิดแท็บหรือหน้าต่างของ Firefox (รวมทั้งเบราว์เซอร์ตัวอื่นๆ)

อาจจะมีบางท่าน กำลังหาโค้ด สำหรับปิดหน้าต่างเบราวเซอร์ หรือปิดแท็บของเบราว์เซอร์ต่างๆ แต่ก็หาไม่ได้ซักที เพราะที่แจกกันก่อนหน้านี้ (เก่า) มักจะใช้ไม่ได้

แต่มาวันนี้ เราจัดเตรียมให้ท่านแล้ว (โค้ดอิงมากจาก KTBonline ของกรุงไทย)<script language="javascript" >
    function closeWindows() {
      //callSingleParseXmlWithCallBack('Login.do?cmd=logout');
      //uncomment to open a new window and close this parent window without warning
      var nAgt = navigator.userAgent;
      if ((verOffset=nAgt.indexOf("MSIE"))!=-1){
            //Close for IE
            window.open('','_parent','');
            window.close();
      }
      else if ((verOffset=nAgt.indexOf("Firefox"))!=-1){
                window.opener=self;
                window.close();
                try{
                  netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
                }catch(e){
                  //alert(e);
                }
                window.open('','_parent','');
                window.close();
      }else {
            openWin=window.open('','_self');
            openWin.close();
      }
    }
</script>
การใช้งาน<a href="javascript:closeWindows();"><img src="/new/resources/themeOne/images/th/images/Button/close.gif" width="86" height="22" /></a>
เอวัง

jaideejung007's

somsak21 โพสต์ 2013-10-6 17:11:14

เจิมด้วย เก็บก่อน ไม่รู้จะทำอะไร {:21_820:}

l3eil3oy โพสต์ 2013-10-6 21:36:17

ขอบพระคุณอย่างยิ่งถ้ามีโอกาศผม จะบวชให้พี่ ครับ sm913dz
หน้า: [1]
ดูในรูปแบบกติ: โค้ด Javascript สำหรับปิดแท็บหรือหน้าต่างของ Firefox (รวมทั้งเบราว์เซอร์ตัวอื่นๆ)