I am using Gecko Web Browser within my VB.NET (Windows Form App) and the web Browser has loaded an local html file. This html has embed in-line a svg file (human body diagram with bones and internal organs) enter image description here with a javascript function for picking up all the "ids" elements from svg document, and then call the javascript function from VB.NET (Windows form app), but I don't know to do the calling. Can anyone help me please, or give me a source code example please? All the stuff I've found is based in C#... This is my javascript function in my HTML FILE:
<script type="text/javascript">
(funcion () {
// Function to be called in VB.NET when the DOM is loaded
var SVGHandler = function () {
// Picking up the id Root Node="CUERPO_HUMANO" into svg variable
var svg = document.querySelector('#CUERPO_HUMANO');
// In Items we save all the <g> which have an ID
var items = svg.querySelectorAll('g[id], path[id]');
//var items = svg.querySelectorAll('g[id]');
// We loop all the nodes saved in Items and add them to click event listener
forEach(items, function (index, value) {
value.addEventListener('click', function (event) {
event.preventDefault();
//We avoid the spread of events
event.stopPropagation();
return event.currentTarget.id
// console.log(event.currentTarget.id)
});
});
}
// http://ift.tt/1WMAJHj
var forEach = function (array, callback, scope) {
for (var i = 0; i < array.length; i++) {
callback.call(scope, i, array[i]); // passes back stuff we need
}
};
// With this method, we call a SVGHandler when DOM is totally loaded
document.addEventListener('DOMContentLoaded', SVGHandler);
})();
IN MY VB.NET FORM: What code should I use in VB.NET for calling my javascript function each time I click on a specific bone or organ over the human body diagram loaded in Gecko Web Browser? I want to save the "id" picked up with the calling into a string variable for being used as a parameter in a SQL statement and populate a datagridview with data. Can anyone help me please? I was searching and all the stuff is referred to C# and any VB.NET example. even though I was trying to figure out the equivalence in VB.NET trying to convert the C# example to VB.NET, I have some doubts how to do the javascript call. According to my javascript function, could be like this?:
browserControl.Navigate("javascript:void(funcion())");
Please, Can anyone help me to solve this?. I would be very thankful...
Aucun commentaire:
Enregistrer un commentaire