好吧,这很愚蠢。我在加载到 WebView 的 HTML 中有一个现有变量,称为caret_position
我想通过我的 Windows Store 应用程序中的 InvokeScriptAsync 检索它。这是我尝试过的。
return await HtmlEditor.InvokeScriptAsync("eval",
new string[] { "return caret_position;" });
return await HtmlEditor.InvokeScriptAsync("eval",
new string[] { "caret_position;" });
这些都不起作用。我可以让它工作的唯一方法是将它写入javascript中的隐藏输入,然后使用这个调用。
return await HtmlEditor.InvokeScriptAsync("eval",
new string[] { "document.getElementById('this_is_silly').value;" });
有没有办法我可以直接访问 javascript 变量,或者我每次都必须跳过这些箍?