How write an AddressBar for Awesomium WebBrowser control

I wrote the codes below for AddressBar of Awesomium WebBrowser control.
A label that can show hovered url…

    private void webBrowser_extra_MouseMove(object sender, MouseEventArgs e)
    {
        string js = @"(function foo(val) { return val; })();
        document.onmouseover = function(e){
            targ = getTarget(e);
            targ.style.border = '1px solid #F00';
            if(targ.tagName == 'A' || targ.tagName == 'a')
            {
                //alert('a');
                var href = targ.getAttribute('href');
                //alert(href);
                foo(href);
            }
        };

        document.onmouseout = function(e){
            getTarget(e).style.border = 'none';
        };

        function getTarget(e){
            if (e.target) return e.target;
            else if (e.srcElement) return e.srcElement;
        }";

        dynamic link = webBrowser_extra.ExecuteJavascriptWithResult(js);
        if (link != null)
        {
                lbl_hover.Text = "Address : " + link;
                toolTip1.SetToolTip(lbl_hover, "Address : " + link);
        }
    }

but i always have [object][object] in lbl_hover!
How can i fix those codes or how can i write better codes for my purpose?


Source: .net

Leave a Reply