var time = 3;
function closeWindow() {
window.setTimeout('closeWindow()', 1000);
if (time > 0) {
document.getElementById("show").innerHTML = " 将倒计时" + time + "秒后关闭当前窗口,返回微信公众号窗口";
time--;
} else {
WeixinJSBridge.call('closeWindow');
//this.window.opener=null;
//关闭窗口时不出现提示窗口
//window.close();
}
}
closeWindow();
把上面的js代码复制走,在你的html里面加个 <div id="show"></div>就ok!!!
或者:
var timeInt = 3
var t = setInterval(function() {
timeInt--
document.getElementsByClassName('timeout')[0].innerHTML=timeInt
if(timeInt <= 0) {
clearInterval(t)
WeixinJSBridge.call('closeWindow');
}
}, 1000)
网友评论