Search code examples
javascriptwebbrowser-controlxulrunner

How to call a function inside a XULRunner browser control?


I'm trying to send parameters to a javascript function embedded in the browser page but with no luck

This is the page script:

    window.loadfile = function(filename){
        dump(filename+" loaded");
    };

I have tried changing the location to javascript:loadfile() but apparently this does not work anymore.


Solution

  • It's ok, I managed to solve this using messages and directly accesing through contentWindow and contentDocument which is even easier:

    document.getElementById("mybrowser").contentWindow.readfile("file.txt");
    

    https://developer.mozilla.org/en-US/docs/The_message_manager