Return an integer/String from NPAPI plugin to JavaScript(Not using FireBreath)

筅森魡賤 提交于 2019-12-11 14:32:17

问题


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.


回答1:


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




回答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);



来源:https://stackoverflow.com/questions/12837946/return-an-integer-string-from-npapi-plugin-to-javascriptnot-using-firebreath

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!