简体   繁体   English

使用 CefSharp 在 c# 中执行脚本时出错

[英]Error executing script in c# using CefSharp

I try to use the next我尝试使用下一个

chromeBrowser.ExecuteScriptAsync("$('#user').setAttribute('value', 'usuario');");

I received the message:我收到消息:

Uncaught ReferenceError: $ is not defined未捕获的 ReferenceError: $ 未定义

When I use the console browser of Chrome it's successfully executed.当我使用 Chrome 的控制台浏览器时,它已成功执行。

You should execute your scripts after your dependencies has been loaded.您应该在加载依赖项后执行脚本。 On browser.LoadingStateChanged event, probably would be the best place for that.browser.LoadingStateChanged事件上,可能是最好的地方。

Look at https://github.com/cefsharp/CefSharp/wiki/General-Usage#when-can-i-start-executing-javascript for more information.查看https://github.com/cefsharp/CefSharp/wiki/General-Usage#when-can-i-start-executing-javascript了解更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM