【发布时间】:2014-05-11 07:42:23
【问题描述】:
在 C# viaGeckoFx 中,我还没有找到查找元素所有属性的方法。
为此,我做了一个JavaScript函数。这是我的代码
GeckoWebBrowser GeckoBrowser = ....;
GeckoNode NodeElement = ....; // HTML element where to find all HTML attributes
string JSresult = "";
string JStext = @"
function getElementAttributes(element)
{
var AttributesAssocArray = {};
for (var index = 0; index < element.attributes.length; ++index) { AttributesAssocArray[element.attributes[index].name] = element.attributes[index].value; };
return JSON.stringify(AttributesAssocArray);
}
getElementAttributes(this);
";
using (AutoJSContext JScontext = new AutoJSContext(GeckoBrowser.Window.JSContext)) { JScontext.EvaluateScript(JStext, (nsISupports)NodeElement.DomObject, out JSresult); }
您是否有其他建议可以在 C#(不使用 Javascript)中实现这一点?
【问题讨论】:
标签: c# javascript gecko geckofx