Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.sao.ru/cats/~satr/JS/plugin/vrsn.htm
Дата изменения: Wed Jan 15 23:19:06 1997 Дата индексирования: Tue Oct 2 05:39:01 2012 Кодировка: Поисковые слова: moon |
This chapter describes the functions that allow a plug-in to display a message on the status line, get agent information, and check on the current version of the Plug-in API and Communicator.
[Top]
NPN_Status
method to display your message on the status line.
void(NPP instance, const char *message); TheNPN_Status
instance
parameter is the current plug-in instance, that is, the one that the status message belongs to. In the message
parameter, pass the string you want to display on the status line.
Communicator always displays the last status line message it receives, regardless of the message source. For this reason, your message is always displayed, but you have no control over how long it stays in the status line before another message replaces it. You should use a different method to display messages that the user needs to see, such as error messages.
[Top] [Displaying a Status Line Message]
user_agent
field. If you want to gather usage statistics or just find out the version of your plug-in's host browser, this information can help you.
The plug-in calls the NPN_UserAgent
method to retrieve the contents of the user_agent
field.
const char* NPN_UserAgent(NPP instance);The
instance
parameter represents the current plug-in instance. This function returns a string that contains the user_agent
field of Communicator.
[Top] [Getting Agent Information]
The Communicator and Plug-in API major version numbers represent code release numbers, and their minor version numbers represent point release numbers. For example, Plug-in API version 4.03 has a major version number of 4 and a point release number of 3.
Differing version numbers may mean that the current Plug-in API and Communicator versions are incompatible. Changes to the minor version numbers indicate a smaller difference than changes to the major version. Changes to the major version numbers probably indicate incompatibility.
The plug-in calls the NPN_Version
method to check for changes in major and minor Plug-in API version numbers. It gets the values from the plug-in rather than from Communicator.
void NPN_Version(int *plugin_major,
This function returns the plug-in version number in
int *plugin_minor,
int *netscape_major,
int *netscape_minor);plugin_major
, the plug-in point release number in plugin_minor
, the Communicator version number in netscape_major
, and the Communicator point release number in netscape_minor
.
This code declares variables to hold the version numbers and calls NPN_Version
to return the major and minor version numbers for Communicator and the Plug-in API.
int plugin_major, plugin_minor, netscape_major,
netscape_minor; // declare variables to hold version numbersvoid NPN_Version(&plugin_major, &plugin_minor, &netscape_major,
[Top] [Getting the Current Version]
&netscape_minor); // find version numbers
NPVERS
constants. Each NPVERS
constant represents a feature. The plug-in can compare the NPVERS
constant to the version number. If the version supports the feature, the plug-in can operate according to plan. If not, the plug-in cannot use some functionality. If an essential feature is unavailable, the developer must arrange for alternative behavior, shut down the plug-in, or give the user a chance to decide what to do. For a listing of version constants defined in the Plug-in API, see "Version Feature Constants."
In this example, the has_windowless
method finds out whether the current version supports windowless plug-ins. It starts by using NPN_Version
to get the version numbers. It then uses the
netscape_minor
version number to find out if the windowless feature, represented by the NPVERS_HAS_WINDOWLESS
constant, is supported. If the method returns true
, a windowless plug-in can confidently proceed. If false
is returned, windowless plug-ins will not work, and the developer must provide alternatives.
Bool has_windowless()
{
int plugin_major, plugin_minor;
int netscape_major, netscape_minor; /* Find the version numbers. */
NPN_Version(&plugin_major, &plugin_minor,
&netscape_major, &netscape_minor); /* Use the netscape_minor version number: */
/* Does this version support the windowless feature? */
if (netscape_minor < NPVERS_HAS_WINDOWLESS) {
/* Plug-in is running in a version of the Navigator */
/* that does not support windowless plug-ins. */
return FALSE;
} else
[Top] [Getting the Current Version]
/* Plug-in is running in a Navigator version */
/* that has windowless support */
return TRUE;
}
Plugins
directory for the platform. If you call NPN_ReloadPlugins
, Communicator reloads all plug-ins in the Plugins
directory without restarting. This causes Communicator to install a new plug-in and load it, or remove a plug-in, without having to restart. Consider using this function as part of the plug-in's SmartUpdate process.
void NPN_ReloadPlugins(NPBool reloadPages);The
reloadPages
parameter is a boolean that indicates whether to reload the page (true
) or not (false
).
[Top] [Reloading a Plug-in]
Last Updated: 01/15/97 16:36:58