Created
March 30, 2018 02:24
-
-
Save liuwenzhuang/d1000648b2d5c72819ea0a5ec9424118 to your computer and use it in GitHub Desktop.
判断window.open打开的页面是否成功;judge whether window.open is blocked or not.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 判断window.open打开页面是否被拦截 | |
| * @return {boolean} true表示被拦截,false表示未被拦截 | |
| */ | |
| function isWindowOpenBlocked() { | |
| var isBlocked = false; | |
| try { | |
| var winRef = window.open(URL, WINDOWNAME[, WINDOWFEATURES]); | |
| if(winRef == null) { // 浏览器拦截 | |
| isBlocked = true; | |
| } | |
| } catch (e) { | |
| isBlocked = true; // 插件、应用拦截 | |
| } | |
| return isBlocked; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment