views:

55

answers:

1

I have a WebBrowser control. I have added some JavaScript into the head tag and I can see it is working as expected by adding an alert. Inside of this js I am creating a function and adding some members to it's prototype like so:

function test() {
}

test.prototype.run = function() {
    alert('success!')
}

function createTest() {
    return new test()
}

Then back inside of C# I am doing:

dynamic test = this.browser.InvokeScript("createTest");
test.run();

I can see that the test object is some ComObject but when I call run() nothing happens. I get no error but nothing happens. Does anyone know how to call this type of custom object?

Also suppose I wanted to get rid of the createTest() method, how can I create a new instance of test from C#?

Also, for bonus points, is there anything special I need to know about attaching events to this custom object (on say a 'complete' member) such that it will callback into my C# code?

A: 

Try passing in an empty System.object array as the second argument to InvokeScript and then call test.run();

Phil Bennett
No dice. Same result.
justin.m.chase