Welcome Guest Search | Active Topics | Sign In | Register

FormatException in WebView.RegisterJSExtensionFunction Options
sando
Posted: Tuesday, January 21, 2014 7:38:42 AM
Rank: Newbie
Groups: Member

Joined: 1/21/2014
Posts: 3
Hi,

I'm trying to register a JS extension function using the code provided in the "Using JavaScript Extension" help page.
I can make it work via the EO.extInvoke, but everytime I use the RegisterJSExtensionFunction on the code, I got a FormatException with following message : "Input string was not in a correct format."
I used the same code written in the Help Page :

Code:

webView1.RegisterJSExtensionFunction("demoAbout", new JSExtInvokeHandler(WebView_JSDemoAbout));

//Extension handler function
void WebView_JSDemoAbout(object sender, JSExtInvokeArgs e)
{
    string browserEngine = e.Arguments[0] as string;
    string url = e.Arguments[1] as string;
    MessageBox.Show("Browser Engine: " + browserEngine + ", Url:" + url);
}



And when the webview is loading i got the exception, when i commented out the RegisterJSExtensionFunction line, it works okay.

Thanks
eo_support
Posted: Tuesday, January 21, 2014 9:10:55 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

We can not think of anything that can cause this problem. Can you try to isolate the problem into a test application and send the test application to us so that we can take a look? We will PM you as to where to send it.

Thanks!
eo_support
Posted: Tuesday, January 21, 2014 9:59:12 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Thank you very much for the test file. We are able to reproduce the problem. We will look into this and get back to you as soon as possible.
eo_support
Posted: Wednesday, January 22, 2014 11:46:24 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

We have posted a new build that should fix this problem. Please see your email for the download location.

Thanks!
sando
Posted: Thursday, January 23, 2014 3:40:52 AM
Rank: Newbie
Groups: Member

Joined: 1/21/2014
Posts: 3
Thanks for the quick response, Ill report back as soon as I get my hands on it and retest it
sando
Posted: Saturday, January 25, 2014 9:47:14 PM
Rank: Newbie
Groups: Member

Joined: 1/21/2014
Posts: 3
Hi,

Sorry for the late report, I just had the time to play with it again a bit, the issue is fixed now.

NOTE:
I think it's important to put here the message you sent along to my pm in case another using the method too ^^.
- once a method is registered via RegisterJSExtensionFunction, the method will be handled by that specific handler and will never get to the JSExtInvoke handler, but it doesn't mean the other method won't be handled by the JSExtInvoke handler.

So we can use both handler on the same webview as long as it handle different method
Code:

    webView.JSExtInvoke += new EO.WebBrowser.JSExtInvokeHandler(webView_JSExtInvoke);
    webView.RegisterJSExtensionFunction("demoAbout", new JSExtInvokeHandler(WebView_JSDemoAbout));


        void WebView_JSDemoAbout(object sender, JSExtInvokeArgs e)
        {
            MessageBox.Show("demo about triggered via register method");
        }

        void webView_JSExtInvoke(object sender, EO.WebBrowser.JSExtInvokeArgs e)
        {
            switch (e.FunctionName)
            {
                case "demoAbout":
                     //this wont be called because the demoAbout method already handled by the WebView_JSDemoAbout.
                     break;
                case "demoHelp":
                    //this will be called if it is triggered in the javascript
                    MessageBox.Show("demo help triggered via invoke event");
                    break;
            }
        }
eo_support
Posted: Monday, January 27, 2014 9:04:05 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Thank you very much for the suggestion and sharing the code. We will update the documentation to explicitly clarify this.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.