Could anyone please explain with a sample...?
How can I return an integer/String from NPAPI plugin(Not using FireBreath) to JavaScript?
I searched a lot ..but can't get a relevant answer.
2 Answers
You need to make a Scriptable class of NPObject: Simple class definition and implementation
You can this post use in Firefox/Chrome browser. Its very similar to your question and has code for the invoke and the JavaScript/html. here.
If you have not read through at least part 1-3 of taxillian's blog on plugins, I would say it is a must read. Read carefully a lot of info I have missed by skimming by when reading.
3 Comments
taxilian
As he says; in particular you need to create a NPVariant with the value you want. int32 is easy (see code.google.com/p/npapi-sdk/source/browse/trunk/headers/… for a helper macro), string is slightly harder because you need to allocate the string using NPN_MemAlloc. See npapi.com/memory
Akhil
Thanks..I just returned an integer value. One more thing is I just want to return a char array to javaScript. How can it possible? char Map[50][50] = {0}; this is that array..I read your tutorials,I can't use fireBreath because of some dependency issues with binaries. so I'm a newbie to NPAPI. Hope you will help.. Could you place some sample?
hapyfishrmn
I have not returned an array personally, but this seems to be you same question: stackoverflow.com/questions/12078250/…