问题描述:在ios中打开的时候总是会跳到appstore上面,并且不会进入到if里面去,如下圖設置的頁面處於隱藏的階段是不行的
if (IS_IOS) {
window.location = "szzx://questionId="+para;
setTimeout(function() {
// If the user is still here, open the App Store
if (!document.hidden) {
// Replace the Apple ID following '/id'
window.location = 'https://itunes.apple.com/cn/app/id1449703627?mt=8';
}
}, 25);
}
解決方法:需要通过visibilitychange,即监控页面是隐藏还是显示的时候,来清除定时器
if (IS_IOS) {
window.location = "szzx://questionId="+para;
var t=setTimeout(function() {
window.location = 'https://itunes.apple.com/cn/app/id1449703627?mt=8';
}, 25);
document.addEventListener(visibilityChange, function() {
clearTimeout(t)
});
}