原创 VB调用webbrowser技巧集2收藏

向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 + "   
    WebBrowser1.Document.Write 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命令。

发表于 @ 2004年07月29日 15:33:00|评论(loading...)

新一篇: vb调用Webbrowser技巧集3 | 旧一篇: VB调用webbrowser技巧集1

用户操作
[即时聊天] [发私信] [加为好友]
陈锐
订阅我的博客
XML聚合  FeedSky
订阅到鲜果
订阅到Google
订阅到抓虾
文章分类
收藏
    Graphics File Formats FAQ
    Adding Custom Buttons to Internet Explorer
    Creating a Windows DLL with Visual Basic
    Graphics File Formats FAQ (Part 1 of 4): General Graphics Format Questions
    Graphics File Formats FAQ (Part 2 of 4): Image Conversion and Display Programs
    Graphics File Formats FAQ (Part 3 of 4): Where to Get File Format Specifications
    Graphics File Formats FAQ (Part 4 of 4): Tips and Tricks of the Trade
    Visual Basic乱七八糟
    朋友的Blog
    小雨的Blog(RSS)
    瓜少之胡言乱语(RSS)
    美女苏胖墩的BLOG
    莫依的博客
    道士摄影
    马宁的Blog(RSS)
    我得主页
    AppleVB
    一些杂七杂八的东西
    40个常用的JS
    存档
    软件项目交易
    Csdn Blog version 3.1a
    Copyright © 陈锐