• 首页
  • 小学语文
  • 中学语文
  • 中学英语
  • 免费论文
  • 教学随笔
  • 学生作文
  • 综合考试
  • 试题教案
  • 育儿话题
  • 教学资源
  • 编程技术
  • 博客
  • VB调用webbrowser技巧集2

    日期:2003-03-26  地址:  作者:

    向Webbrowser中写入HTML内容的几种方法

    首先在Form_Load中加入

    WebBrowser1.Navigate "about:blank"

    确保Webbrowser1可用

     

    方法1:

        Dim s As String    Dim stream As IStream           s = ""    s = s + ""    s = s + ""    s = s + "

    hello world

    "    s = s + ""    s = s + "

     

    方法2:

        Dim o       Set o = WebBrowser1.Document.selection.createrange    Debug.Print o    If (Not o Is Nothing) Then        o.pasteHTML "哈哈"        Set o = Nothing    End If

     

    方法3:

        '插入文本框    Dim o

        Set o = WebBrowser1.Document.selection.createrange        o.execCommand "InsertTextArea", False, "xxx"

     

    其中方法3是采用了调用execCommand并且传递控制命令的方法,通过这种方法还可以插入图片等页面元素,详情可以参考MSDN的execCommand命令。

    对 VB调用webbrowser技巧集2 文章的评论    [查看网友评论]

    验证码:
    匿名发表: