var xmlHttp; function createXMLHttpRequest() { try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(sc) { xmlHttp = null; } } if( !xmlHttp && typeof XMLHttpRequest != "undefined" ) { xmlHttp = new XMLHttpRequest(); } return xmlHttp; } function showDiv() { var iWidth = document.documentElement.clientWidth; var iHeight = document.documentElement.clientHeight; var bgObj = document.getElementById("divbg"); bgObj.style.cssText = "position:absolute;left:0px;top:0px;width:"+iWidth+"px;height:"+Math.max(document.body.clientHeight, iHeight)+"px;filter:Alpha(Opacity=30);opacity:0.3;background-color:#000000;z-index:1;"; // 獲得事件Event對象,用於相容IE和FireFox function getEvent() { return window.event || arguments.callee.caller.arguments[0]; } document.getElementById('popDiv').style.display='block'; document.getElementById('divbg').style.display='block'; } function closeDiv() { document.getElementById('popDiv').style.display='none'; document.getElementById('divbg').style.display='none'; } function readPDF(FDF_ID) { var url = "readpdf.aspx?login=false&id=" + FDF_ID + "&r=" + Math.random(); start_Login(url); } function Subscribe() { var url = "Subscribe.aspx?Subscribe=true&login=false&r=" + Math.random(); createXMLHttpRequest(); xmlHttp.onreadystatechange = handleState_Subscribe; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function start_Login(url) { createXMLHttpRequest(); xmlHttp.onreadystatechange = handleState_Login; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function handleState_Login() { if(xmlHttp.readyState==4) { if(xmlHttp.status==200) { var j = xmlHttp.responseText.parseJSON(); if(j.islogin == "false") { alert(j.Reason); showDiv(); } else { //debugger closeDiv(); if(j.exitfile == "true") { //alert(j.filepath); top.location.href = "http://" + window.location.host + "/" +j.filepath; } else { if(j.Reason == "") { alert(j.filepath); } else { alert(j.Reason); } } } } } } function handleState_Subscribe() { if(xmlHttp.readyState==4) { if(xmlHttp.status==200) { var j = xmlHttp.responseText.parseJSON(); if(j.islogin == "false") { alert(j.Reason); showDiv(); } else { alert(j.Reason); closeDiv(); } } } } function pop_Login() { var UserName = document.getElementById("pop_username").value; if(UserName.length == 0) { alert("請輸入使用者名稱"); return false; } var PassWord = document.getElementById("pop_password").value; if(PassWord.length == 0) { alert("請輸入密碼"); return false; } if(UserName.length > 0 && PassWord.length > 0) { var url = "readpdf.aspx?Login=true&UserName=" + UserName + "&PassWord=" + PassWord + "&r=" + Math.random(); start_Login(url); } } function Subscribe_Login() { var UserName = document.getElementById("pop_username").value; if(UserName.length == 0) { alert("請輸入使用者名稱"); return false; } var PassWord = document.getElementById("pop_password").value; if(PassWord.length == 0) { alert("請輸入密碼"); return false; } if(UserName.length > 0 && PassWord.length > 0) { var url = "Subscribe.aspx?Subscribe=true&login=true&UserName=" + UserName + "&PassWord=" + PassWord + "&r=" + Math.random(); createXMLHttpRequest(); xmlHttp.onreadystatechange = handleState_Subscribe; xmlHttp.open("GET",url,true); xmlHttp.send(null); } } |