请教如何在ocx中创建HTML元素并将它们插入到页面而不是用“页面设计器”。我用了insertAdjacentHTM方法不行!
谢谢!

解决方案 »

  1.   

    我的代码是ocx中动态生成一个html的元素:file(就是用于上传文件的那个组件,点击“浏览”,选择文件),我的代码是这样写的:
    Private Sub Command1_Click()
    Dim inputname As String
    Dim oDoc As HTMLDocument
    Dim oFileInput As HTMLFormElement
    Dim odiv As HTMLDivElement
    Dim pathname As String
    inputname = "name1"
    Dim pathname  As stringSet oDoc = New HTMLDocument
    '生成一个file
    Set oFileInput = oDoc.createElement("input")
    oFileInput.setAttribute "name", inputname
    oFileInput.setAttribute "id", inputname
    oFileInput.setAttribute "type", "file"
    oFileInput.outerHTML = "<input type='file' id='" + inputname + "' name='" + inputname + "' >"'打开file
    oFileInput.click
    pathname=oFileInput.value
    debug.print pathname
    end sub
    问题是:我在html里加载这个ocx后,单击“command1”后,没有任何的反应?当然也就得不到pathname的值。另外:我引用的是“Microsoft HTML Object Library”,没有使用“页面设计器”。请高手指点我的代码有什么问题?
      

  2.   

    我曾经出1000分,问控件和html的通讯,不是和你的正好相反.我是要求activex按件来控制引用它的html上的某个元素.至今未没有解决.
      

  3.   

    我发现着方面的资料太少了,msdn也没给什么!我是想用方法来写一个上传的控件!
      

  4.   

    写文件,建议按HTML格式写读元素引用Microsoft HTML Object Library,
    getelementsbyname