0

In javascript my code will be as follows:

function start() {  

  var start = document.getElementById('start'); //start is object for my plugin
  if(start){
    getAsLoad(start);
  }
} 
function getAsLoad(startObj) {
var load = startObj.startMethod();

  // Handle progress, success, and errors
  load.onload = loaded;
  load.onerror = errorHandler;
}

function loaded(evt) {  
  var StringData = evt.target.result;
  alert(StringData);      
} // Like loaded similar code for errorHandling

How to start it in plain NPAPI Plugin , the event handling mechanism , I know in firebreadth it is a cakewalk , as per my requirement i can't use it. so this kind of thing i have to implement in NPAPI Plugin. Thanks in advance.

1 Answer 1

1

The easiest way to do it would be to have javascript call your plugin.

If you want to do it from the plugin, though, you just get the DOM window NPObject and start Invoking methods and getting properties, etc.

For example, to get "start" you could call getProperty with "document", then call Invoke on the resulting NPObject with "getElementById" and "start" as the parameter.

The tricky part comes up if you want a callback into your plugin, in which case you'll have to create an NPObject that handles InvokeDefault which is what will be called when the callback fires. It's a bit of a pain, but from there the details are the same as javascript, just a little more cumbersome

5
  • taxilian as u explained , is there any code sample to implement in NPAPI or any useful link .
    – r_tex
    Sep 13, 2012 at 15:34
  • 1
    Basically it's the same technique used in stackoverflow.com/questions/12078250/…
    – taxilian
    Sep 13, 2012 at 16:28
  • I got it taxilian , my only concern is load.onload=loaded;load.onerror = errorHandler; onload property i'll have to define in my plugin, after getting property onload do i have to call NPN_InvokeDefault on a NPObject or other things as right side is loaded function. load.onload =loaded ; will work.
    – r_tex
    Sep 13, 2012 at 17:16
  • 1
    you have to provide a npobject that the browser will call NPN_InvokeDefault on; that npobject should be used for "loaded". then you just use SetProperty on the load to set "onload" to that npobject
    – taxilian
    Sep 13, 2012 at 17:27
  • I am using setProperty on the load to set "onload". If the name is different than onload .It works fine , but when i set the onload i get null in javascript.
    – r_tex
    Sep 15, 2012 at 15:39

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.