2

am using asp.net with Jquery, Javascript and flash.

Problem: I want to launch a window for install flash at client end(if not flash is not installed).

I used below javascript code to detect if flash is installed or not.

function detectFlash() {
    var hasFlash = false;
    try {
        var fo = (navigator.mimeTypes && navigator.mimeTypes['application/x-shockwave-flash']) ? navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin : 0;
        if (fo) {
            hasFlash = true;
        }
    } catch (e) {
        if (navigator.mimeTypes['application/x-shockwave-flash'] != undefined) {
            hasFlash = true;
        }
    }
    if (hasFlash) {
        alert("flash is installed");
    }
}

but using above code I got only true or false if installed or not. but if not installed then how can I launch window to install flash using Javascript/JQuery or asp.net

How can I achieve this?

Ionică Bizău
  • 109,027
  • 88
  • 289
  • 474
prog1011
  • 3,425
  • 3
  • 30
  • 57

2 Answers2

3

Just make a redirect:

function detectFlash() {
    var hasFlash = false;
    try {
        var fo = (navigator.mimeTypes && navigator.mimeTypes['application/x-shockwave-flash']) ? navigator.mimeTypes['application/x-shockwave-flash'].enabledPlugin : 0;
        if (fo) {
            hasFlash = true;
        }
    } catch (e) {
        if (navigator.mimeTypes['application/x-shockwave-flash'] != undefined) {
            hasFlash = true;
        }
    }
    if (hasFlash) {
        alert("flash is installed");
    } else {
        location = "http://www.adobe.com/software/flash/about/";
    }
}

You can try to open it in a new tab (browsers may block such actions):

Enabling Flash plugin via JavaScript

Seriously, this is impossible (leave a comment if I'm wrong). Only the user is supposed to be able to enable this. Since this is a browser setting, this is different from a browser to another:

Unless the browsers don't expose a JavaScript API to enable this feature, we have this limitation.

Community
  • 1
  • 1
Ionică Bizău
  • 109,027
  • 88
  • 289
  • 474
  • this is correct but I want to launch a window which will ask to install – prog1011 Oct 27 '14 at 06:56
  • @Prog You cannot do that cross-platform. The best way is to let the user choose what to install. – Ionică Bizău Oct 27 '14 at 06:58
  • yes it is better to let user choose it. Can you tell me how we can enable flash plugin for browser using javascript/Jquery? – prog1011 Oct 27 '14 at 07:03
  • @Prog This is impossible, too. Such actions should be done by user, not by client scripts. You can show a friendly message instead (*Please install/enable flash.*). – Ionică Bizău Oct 27 '14 at 07:08
  • are you sure that using client script we can not enable/disable plugin for browser? please give me link or reference for that :) – prog1011 Oct 27 '14 at 07:25
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/63690/discussion-between-ionic-bizu-and-prog). – Ionică Bizău Oct 27 '14 at 07:27
1

You can redirect the page to this URL once hasFlash is false.

http://download.macromedia.com/pub/flashplayer/current/support/install_flash_player.exe

Alvin Magalona
  • 771
  • 3
  • 13