1

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 2

2

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.

Part 1

Part 2

Part 3

Sign up to request clarification or add additional context in comments.

3 Comments

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
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?
I have not returned an array personally, but this seems to be you same question: stackoverflow.com/questions/12078250/…
2

Found a solution.
Returning a string from NPAPI plugin

char* npOutString = (char *)pNetscapefn->memalloc(strlen(StringVariable) + 1);

if (!npOutString) return false; strcpy(npOutString, StringVariable); STRINGZ_TO_NPVARIANT(npOutString, *result);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.