c # with javascript get src from the image using MouseDoubleClick cefsharp

0

<html lang="pt-br"> <head><title></title></head><body><img id="1" alt="1" src="http://www.imagenspng.com.br/wp-content/uploads/2015/06/imagenspng_logo4.png"style="width: 150px; height: 150px;" /><img id="2" alt="2" src="http://www.imagenspng.com.br/wp-content/uploads/2016/04/peppa-pig-01.png"style="width: 150px; height: 150px;" /><img id="3" alt="3" src="http://www.imagenspng.com.br/wp-content/uploads/2016/04/peppa-pig-02.png"style="width: 150px; height: 150px;" /></body></html>

Hello friends, could you help me how to get the image link with javascript or c # I'm doing this

  var res14 = await chromeBrowser1.EvaluateScriptAsync("document.getElementsByTagName('img')[2].src");

However, in this case it only brings the src of image 2, but when clicking on image 1 or any other image it will bring the path. Thank you all

    
asked by anonymous 30.06.2017 / 05:37

1 answer

1

Pretty simple, just use onclick in your HTML .

function selectAvatar(el) {
    var imgSrc = el.src;
    window.alert(imgSrc);
}
<img onclick="selectAvatar(this)" src="https://2gether4good.files.wordpress.com/2010/07/1_2_3.jpg"><imgonclick="selectAvatar(this)" src="http://www.clker.com/cliparts/G/V/k/w/7/Z/two-green-square-rounded-edge-th.png"><imgonclick="selectAvatar(this)" src="http://pngimg.com/uploads/number4/number4_PNG15037.png?i=1">
    
30.06.2017 / 05:54