As far as I know, popup blockers works by overwrite a window.open
function and in most cases return a null
. So one way is to detect if window.open
is still nativ function.
You can test that with toString
method, which return [native code]
as a body of that function. toString
not work in old IE, so instead of that use ''+
to convert function.
var havePopupBlockers = ('' + window.open).indexOf('[native code]') === -1;
This is not silver bullet, but can detect potential risk. I test this on Chrome, FF, IE8 and IE9 with some various popup blockers and works.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…