I am writing a safari plugin with NPAPI. How can I return an integer from NPAPI plugin(Not using FireBreath) to JavaScript? javascript:
<html>
<head>
<script>
function run() {
var plugin = document.getElementById("pluginId");
var number = plugin.getBrowserName();
alert(number);
}
</script>
</head>
<body >
<embed width="0" height="0" type="test/x-open-with-default-plugin" id="pluginId">
<button onclick="run()">run</button>
</body>
</html>
plugin code:
bool plugin_invoke(NPObject *obj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result) {
// Make sure the method called is "open".
NPUTF8 *name = browser->utf8fromidentifier(methodName);
if(strcmp(name, plugin_method_name_getBrowserName) == 0) {
//what can i do here?
}
return true;
}
How to return a number from plugin.getBrowserName()?
Plz help!
I am find this thread:Return an integer/String from NPAPI plugin to JavaScript(Not using FireBreath), but i don't know where are these code
char* npOutString = (char *)pNetscapefn->memalloc(strlen(StringVariable) + 1);
if (!npOutString) return false; strcpy(npOutString, StringVariable);
STRINGZ_TO_NPVARIANT(npOutString, *result);
put.