Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
332 views
in Technique[技术] by (71.8m points)

javascript - Modern or Non-deprecated way to detect flash player with js/jquery?

First of all, sorry for ressurrecting this question here. I've been trying for two days how to reach this job using javascript/jquery and i think i've read all stack overflow and other blogs posts about that, so please, don't mark it as duplicated because I can't use out-dated scripts from 2012 now in 2017.

I've a single page that redirects to a third party e-learning platform where some content needs flash to work. Many users don't care about which software is installed on their machines (what a new, huh) so i need to detect it and show the tipical message "please install/update flash player clicking here", but i cannot find a "modern" script/way to do this, in any place, simplified, if possible.

All scripts i've tried are deprecated or returns false in all browsers, even i've newest version of flash installed and active.

Anny help will be appreciated (except links to older posts or scripts that don't work nowadays, obviously).

Thanks a lot!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There is a simple way to check for Flash since all the installed and enabled plugins will be listed in navigator.plugins;

Note that if a plugin is installed, but not enabled, it will not be detected in the navigator.plugins array. There is NO way to detect this using Javascript (this Question which confirms the same).

Having said that, use the following function isFlashEnabled(); to detect Flash :

<html>

<script>

if(isFlashEnabled()) 
{ document.write('Flash is installed (but may need to be enabled)'); } 
else { document.write('Flash is either not installed or disabled'); }

function isFlashEnabled() 
{
    var flash = navigator.plugins.namedItem('Shockwave Flash');
    if (!flash) { return 0; } 
    else { return 1; }
}

</script>

<body> <embed src="https://www.w3schools.com/tags/helloworld.swf"> </body>

</html>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...