Get started with Bridge.NET CDN

Apache-2.0 licensed

Bridge.NET is a Microsoft project that enables .NET developers to call JS and vice versa in the same process.

Tags:
  • Bridge.NET
  • JavaScript
  • Compiler

Stable version

Copied!

How to start using Bridge.NET CDN


using System;
using System.Runtime.InteropServices.JS;

namespace BridgeNetExample
{
    class Program
    {
        static void Main(string[] args)
        {
            // Initialize Bridge.NET
            JSContext.Attach(new JSContext());
            JSRuntime.GlobalObject = JSContext.Current.GlobalObject;

            // Load the Bridge.NET library from the CDN
            JSRuntime.InvokeVoid("eval", new JsString("(function() { window.Bridge = Bridge || {}; Bridge.loadScript = function(url, callback) { var s = document.createElement('script'); s.src = url; s.onload = callback; document.head.appendChild(s); }; })();"));
            Bridge.loadScript("https://cdn.cdnhub.io/Bridge.NET/17.10.1/bridge.min.js", () =>
            {
                // Call a JavaScript function from Bridge.NET
                Bridge.callAll("alert", "Hello from Bridge.NET!");
            });

            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
    }
}
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions