1

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?

SilverLight
  • 19,668
  • 65
  • 192
  • 300
  • this may help you. http://stackoverflow.com/questions/13280727/can-i-call-application-methods-from-javascript-in-awesomium. bind jquery hover event with on jquery hover event call C#.net function by following above link. – sm.abdullah Jul 03 '15 at 09:14

1 Answers1

2

If you need to know a hovered URL, then for this purpose Awesomium WebControl has an event TargetURLChanged.

/// <summary>
/// Occurs when the target URL has changed. This
/// is usually the result of hovering over a link on a page.
/// </summary>
public event UrlEventHandler TargetURLChanged;
Alex Zhevzhik
  • 3,347
  • 19
  • 19