window.onload = function () { var tmpParams = getQueryString(window.location); if (tmpParams != null) { console.log(JSON.stringify(tmpParams)); if (tmpParams.trade_no == "success") { getResponse("success"); } else { getResponse("fail"); } //alertMsg("支付返回参数:" + JSON.stringify(tmpParams)); } else { console.log("支付返回参数" + tmpParams); } } //type[fail、sucesss] function getResponse(type) { var img = document.getElementById("stateImg"); var label = document.getElementById("stateLable"); if (type == "fail") { img.src = "img/no.png"; label.innerHTML = "支付失败,尝试重新扫码"; setTimeout(function () { alert('1') if (navigator.userAgent.indexOf("MSIE") > 0) { if (navigator.userAgent.indexOf("MSIE 6.0") > 0) { window.opener = null; window.close(); } else { window.open('', '_top'); window.top.close(); } } else if (navigator.userAgent.indexOf("Firefox") > 0) { window.location.href = 'about:blank '; //火狐默认状态非window.open的页面window.close是无效的 //window.history.go(-2); } else { window.opener = null; window.open('', '_self', ''); window.close(); } }, 2000) } else { img.src = "img/ok.png"; label.innerHTML = "订单支付成功"; setTimeout(function () { if (navigator.userAgent.indexOf("MSIE") > 0) { if (navigator.userAgent.indexOf("MSIE 6.0") > 0) { window.opener = null; window.close(); } else { window.open('', '_top'); window.top.close(); } } else if (navigator.userAgent.indexOf("Firefox") > 0) { window.location.href = 'about:blank '; //火狐默认状态非window.open的页面window.close是无效的 //window.history.go(-2); } else { window.opener = null; window.open('', '_self', ''); window.close(); } }, 2000) } }