在浏览器c#中注入javascript命令

Inject javascript command on webbrowser c#

本文关键字:javascript 命令 注入 浏览器      更新时间:2023-09-26

我想在web浏览器上注入这个命令。我该怎么做呢?

oFormObject = document.forms['formid'];  
oFormObject.elements["name"].value = 'Some Value';
document.getElementById('formid').submit();

你需要仔细阅读ClientScriptManager.RegisterClientScriptBlock

StringBuilder csText = new StringBuilder();
      csText.Append("<script type='"text/javascript'"> function DoClick() {");
      csText.Append("Form1.Message.value='Text from client script.'} </");
      csText.Append("script>");
      cs.RegisterClientScriptBlock(csType, csName, csText.ToString());