我在我的VB.NET
(Windows Form App)程序中使用GeckoWebBrowser
。 GeckoWebBrowser
加载本地文件html
。该html
嵌入了内嵌svg
文件(human body diagram with bones and internal organs)与javascript
函数,用于从svg
文档中提取元素的所有“ID”。我想从VB.NET
(Windows窗体应用程序)调用前述javascript
函数,但我不知道如何去做。任何人都可以帮助我,或者请给我一个源代码示例吗?所有我发现的东西是基于在C#
... 这是我javascript
功能在我html
文件:VB.NET Gecko Web浏览器JavaScript函数调用?
<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)
});
});
}
// https://toddmotto.com/ditch-the-array-foreach-call-nodelist-hack/
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);
})();
</script>
什么代码,我应该在VB.NET
使用,每次我点击一个打电话给我的javascript
功能GeckoWebBrowser
加载的人体图中特定的骨或器官? 我想将通过调用获取的“id”保存为string
变量,以便将其用作SQL
语句中的参数并填充DataGridView
。 我一直在寻找,所有我能找到的与C#
有关,而不是一个VB.NET
的例子。尽管我试图找出VB.NET
尝试将C#
的示例转换为VB.NET
的等价性,但我对如何执行javascript
调用存在一些疑问。据我javascript
功能它可能是这样的:
browserControl.Navigate("javascript:void(funcion())");
请,任何人都可以帮我解决这个问题?我会非常感谢...