Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Global window object

$
0
0
Yes, I was exposing the window object like this:
var engine = new V8ScriptEngine();
engine.AddHostObject("window", new Window());
Then I can have a class Window that looks like this:
using System;

namespace foo
{
    public class Window
    {
        public void alert(string msg)
        {
            Console.WriteLine("alert: " + msg);
        }
    }
}
Now a script can use window.alert("foo") can it will come out on the console. What I need is to set the global object to window, so I can call just alert("foo"); from a script

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images