c# with javascript catch image src using Mousedoubleclick cefsharp

Asked

Viewed 201 times

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>

good morning friends, could help me how to get the image link with javascript or c# I am doing this

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

but in this case it only brings the src of image 2, but need that when you click on image 1 or any other image it brings the way. Grateful to all

  • Welcome to Stackoverflow, Kelly! You want to add function to a mouse click on an image, is that it? Can you clarify what you mean by "bring the image path"? Please edit your question and include all information you can about what you intend to do.

1 answer

1

Very simple, just use onclick in his 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">
<img onclick="selectAvatar(this)" src="http://www.clker.com/cliparts/G/V/k/w/7/Z/two-green-square-rounded-edge-th.png">
<img onclick="selectAvatar(this)" src="http://pngimg.com/uploads/number4/number4_PNG15037.png?i=1">

  • I don’t know how I do it function selectAvatar(el) { var imgSrc = el.src; window.alert(imgSrc); } turn something like this because I’m using c# var res14 = await chromeBrowser1.EvaluateScriptAsync("document.getElementsByTa‌​gName('img')[2].src"‌​);

  • Okay, but how I’m going to get it over to Vb.net

Browser other questions tagged

You are not signed in. Login or sign up in order to post.