• C#程序 给IE网页IFRAME控件中所嵌入网页的元素赋值


     1

    //引用COM组件
    //Microsoft HTML Object Library
    //Microsoft Internet Controls

      
    SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass(); 2 string filename; 3 foreach (SHDocVw.InternetExplorer ie in shellWindows) 4 { 5 filename = Path.GetFileNameWithoutExtension(ie.FullName).ToLower(); 6 if (filename.Equals("iexplore")) 7 { 8 SetText(string.Format("Web Site  : {0}", ie.LocationURL)); 9 mshtml.IHTMLDocument2 htmlDoc = ie.Document as mshtml.IHTMLDocument2; 10 SetText(string.Format("  Document Snippet: {0}", 11 ((htmlDoc != null) ? htmlDoc.body.outerHTML 12 : "***Failed***"))); 13 SetText(string.Format("{0}{0}", Environment.NewLine)); 14 15 mshtml.HTMLInputElementClass input; 16 mshtml.HTMLIFrameClass iframe; 17 mshtml.IHTMLDocument2 target; 18 //获取父页面框架集合. 19 mshtml.IHTMLFramesCollection2 frames = htmlDoc.frames; 20 for (int i = 0; i < frames.length; i++) 21 { 22 object index = i; 23 mshtml.IHTMLWindow2 frame = frames.item(ref index) as mshtml.IHTMLWindow2; 24 25 mshtml.IHTMLDocument2 frameDoc = frame.document as mshtml.IHTMLDocument2; 26 //现在你可以通过frameDoc获取子页面控件. 27 28 if (frame.location.href.Contains("zzs_fp.html")) 29 { 30 target = frameDoc; 31 32 33 foreach (mshtml.IHTMLElement ieElement in target.all) 34 { 35 if (ieElement.tagName.ToUpper().Equals("INPUT")) 36 { 37 input = ((mshtml.HTMLInputElementClass)ieElement); 38 39 SetText("input.name:" + input.name); 40 SetText(string.Format("{0}{0}", Environment.NewLine)); 41 42 if (input.name == "ghdwmc") 43 { 44 input.value = "****"; 45 } 46 else if (input.name == "ghdwsh") 47 { 48 input.value = "12300000747150428A"; 49 } 50 else if (input.name == "ghdwdzdh") 51 { 52 input.value = "北京市 010-512011"; 53 } 54 else if (input.name == "ghdwyhzh") 55 { 56 input.value = "北京银行 132465798798"; 57 } 58 } 59 } 60 } 61 } 62 } 63 }
  • 相关阅读:
    dinoql 试用
    dinoql 使用graphql 语法查询javascript objects
    使用git_stats 统计分析git 仓库代码&& 集成webhook
    使用gitstats分析git 仓库代码
    PostGraphile 4.4 发布,支持real time 查询
    cube.js 学习(十)cube 来自官方的学习网站
    Optimize Cube.js Performance with Pre-Aggregations
    cube.js 学习(九)cube 的pre-aggregation
    cube.js 学习(八)backend部署模式
    cube.js 学习(七)cube.js type 以及format 说明
  • 原文地址:https://www.cnblogs.com/dyfisgod/p/8602695.html
Copyright © 2020-2023  润新知