Suppose you have written some custom JavaScript to harness the capabilities provided by a specific plug-in. When users visit your page without the plug-in they are prompted to install it because you have included the proper pluginspage attribute in your. Unfortunately, if a user visits your page without the plug-in, agrees to download and install it, and then returns to your page, your JavaScript will not detect that the browser has the required plug-in. The reason is that the plugins[] array needs to be refreshed whenever a new plug-in is installed (a browser restart will work as well).
Refreshing the plugins[] array is as simple as invoking its refresh()method. Doing so causes the browser to check for newly installed plug-ins and to reflect the changes in the plugins[] and mimeTypes[]arrays. This method takes a Boolean argument indicating whether the browser should reload any current documents containing an .If you supply true, the browser causes any documents (and frames) that might be able to take advantage of the new plug-in to reload. If false is passed to the method, theplugins[] array is updated, but no documents are reloaded. A typical example of the method’s use is found here:
If you have just installed the plugin, please reload the page with plugin support
function detectUnityWebPlayer () {
navigator.plugins.refresh(true);
var tInstalled = false;
if (navigator.appVersion.indexOf("MSIE") != -1 &&
navigator.appVersion.toLowerCase().indexOf("win") != -1)
{
tInstalled = detectUnityWebPlayerActiveX();
}
else if (navigator.mimeTypes && navigator.mimeTypes["application/vnd.unity"])
{
if (navigator.mimeTypes["application/vnd.unity"].enabledPlugin &&
navigator.plugins && navigator.plugins["Unity Player"])
{
tInstalled = true;
}
}
if(tInstalled == false){
document.getElementById("unity_div").style.display="block";
document.getElementById("unity_div2").style.display="none";
}
}
function detectUnityWebPlayerActiveX()
on error resume next
dim tControl, res, ua, re, matches, major
res = 0
set tControl = CreateObject("UnityWebPlayer.UnityWebPlayer.1")
if IsObject(tControl) then
if tControl.GetPluginVersion() = "2.5.0f5" then
' 2.5.0f5 on Vista and later has an auto-update issue
' on Internet Explorer. Detect Vista (6.0 or later)
' and in that case treat it as not installed
ua = Navigator.UserAgent
set re = new RegExp
re.Pattern = "Windows NT (\d+)\."
set matches = re.Execute(ua)
if matches.Count = 1 then
major = CInt(matches(0).SubMatches(0))
if major <>
res = 1
end if
end if
else
res = 1
end if
end if
detectUnityWebPlayerActiveX = res
end function