Hi,
I'm developing an npapi plugin. I am trying to inject a script into the current webpage of the browser,but am not able to do it. Any hints or suggestions as to how i should proceed with it, would be really helpful.
Thanks
Hi,
I'm developing an npapi plugin. I am trying to inject a script into the current webpage of the browser,but am not able to do it. Any hints or suggestions as to how i should proceed with it, would be really helpful.
Thanks
Use NPN_Evaluate to execute javascript source code.
If you want to 'inject a script' that's in a separate js file, use NPN_Evaluate to add a script tag to the document. (Let me know if you need an example.)
The best way to interact with javascript, depending on what you're doing, is either NPN_Evaluate (if nothing else will work) or by using NPN_GetValue to get the NPObject for the DOM window and then you can call Invoke and SetProperty on that.
If you're just injecting straight javascript, of course, NPN_Evaluate is a good way to do that, but avoid using that on things that get called really often, as it does have a performance hit compared to talking to the dom objects directly.