比如网页中有两个按钮,原本按钮1是弹出一个新窗口,访问www.sina.com,按钮2是弹出一个新窗口,访问www.sohu.com,能否修改后让按钮1访问www.163.com,按钮2访问www.126.com?也就是修改其中的代码,只需要将其中的www.sina.com替换成www.163.com、www.sohu.com替换成www.126.com,(注:假定上面的代码如www.sina.com、www.sohu.com都能从“查看源文件”里面直接看到),谢谢。

解决方案 »

  1.   

    Handling HTML Element Events
      

  2.   

    IE的接口是COM,和语言无关。不会用VB调用COM的话,先去学COM。
      

  3.   

    希望这个对你有帮助http://blog.csdn.net/hui717/archive/2007/10/29/1854438.aspx
      

  4.   

    如果是使用IE窗口,修改後將無法遞交。——因為IE出於安全的考慮,已經不允許氾濫地跨域遞交。
      

  5.   

    我用的是webbrowser,请问怎么办?谢谢
      

  6.   

    获取webbrowser的IHtmlDocuments接口,然后获取IHTMLElement接口
    CComPtr<IHTMLElement>   spDispElements;   
    hr=spDocument2->get_body(&spDispElements); 
    得到spDispElements后,spDispElements->get_innerHTML(保存数据的wstring)
    然后就是替换wstring中你需要改的内容,接着spDispElements->put_innerHTML(新的wstring)
      

  7.   

    谢谢
    楼上的意思大约是:webbrowser1.document.body.innerHTML=新的内容吗(该方法无效)?还是每个元素的innerHTML?
      

  8.   

    http://topic.csdn.net/t/20050508/15/3989537.html  Dim   texbody   As   HTMLBody       
      Private   Sub   Command1_Click()   
              texbody.innerHTML   =   "<h1>动态生成网页</h1>"   
      End   Sub   
        
      Private   Sub   Form_Load()   
              WebBrowser1.Navigate   "about:"   
      End   Sub   
        
      Private   Sub   WebBrowser1_DocumentComplete(ByVal   pDisp   As   Object,   URL   As   Variant)   
              Set   texbody   =   WebBrowser1.Document.body   
      End   Sub注意vb6 的对象必须用set 赋值直接 webbrowser1.document.body.innerHTML=××× 是无效的
      

  9.   

      Dim docobj, tagobj As Object
       Dim tint As Integer
       '得到html的所有元素
       Set docobj = Me.WebBrowser1.Document
       '循環查找hidden元素
       For tint = 0 To docobj.All.length - 1       If UCase(docobj.All(tint).tagName) = "INPUT" Then          Set tagobj = docobj.All(tint)          If tagobj.Type = "hidden" Then              If tagobj.Name = "ulogin" Then
                     tagobj.Value = usernm
                  End If              If tagobj.Name = "upsw" Then
                     tagobj.Value = userpsw
                  End If              If tagobj.Name = "httpurl" Then
                      tagobj.Value = getsvrIP & "/" & getsvrsitenm
                  End If          End If
           End If   Next看看這樣能不能改變他的onclick的值
      

  10.   

    Private Sub Command1_Click()
    WebBrowser1.Navigate "http://www.baidu.com"
    End SubPrivate Sub Command2_Click()
    WebBrowser1.Document.body.innerHTML = Replace(WebBrowser1.Document.body.innerHTML, "www.baidu.com", "www.lolong.com")
    End Sub