Ejemplo n.º 1
0
    /// <summary>
    /// Adds a JavaScript to current page.
    /// </summary>
    /// <param name="jsString">The JavaScript code to add. It should be a valid JavaScript statement string.</param>
    /// <param name="completionHandler">Called when adding JavaScript operation finishes. Default is `null`.</param>
    public void AddJavaScript(string jsString, Action <UniWebViewNativeResultPayload> completionHandler = null)
    {
        var identifier = Guid.NewGuid().ToString();

        UniWebViewInterface.AddJavaScript(listener.Name, jsString, identifier);
        if (completionHandler != null)
        {
            payloadActions.Add(identifier, completionHandler);
        }
    }
Ejemplo n.º 2
0
        /// <summary>
        /// Add some javascript to the web page.
        /// </summary>
        /// <param name="script">Some javascript code you want to add to the page.</param>
        public void AddJavaScript(string script)
        {
            Setup();

#if UNIWEBVIEW3_SUPPORTED
            UniWebViewInterface.AddJavaScript(listener.Name, script, string.Empty);
#elif UNIWEBVIEW2_SUPPORTED
            UniWebViewPlugin.AddJavaScript(listener.Name, script);
#else
            WWebViewPlugin.AddJavaScript(listener.Name, script);
#endif
        }