<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>无标题文档 </title> 
<script language="javascript"> 
function btn_click() 

    var obj = document.getElementById("obj");
var txt = document.getElementById("txt").value;
obj.属性 = txt;
obj.方法  (txt);
} </script> 
</head> <body> <OBJECT id="obj" style="DISPLAY: none" codeBase="......."
    classid="...." viewastext>
</OBJECT>
            
<input id="txt" /><input type="button" onclick="btn_click()" />
</body> 
</html> 

解决方案 »

  1.   

    请问一下,我照您的样子把代码加在我用WORDPAD产生的一个空白网页里,一输入字符串再一点,IE提示网页上有错误,请费心给看看这是怎么回事情.<html xmlns:o="urn:schemas-microsoft-com:office:office"
    xmlns:w="urn:schemas-microsoft-com:office:word"
    xmlns="http://www.w3.org/TR/REC-html40"><head>
    <meta http-equiv=Content-Type content="text/html; charset=GB2312">
    <meta name=ProgId content=Word.Document>
    <meta name=Generator content="Microsoft Word 9">
    <meta name=Originator content="Microsoft Word 9">
    <link rel=File-List href="./Test%20Ocx%20use.files/filelist.xml">
    <title>Test Ocx use</title>
    <!--[if gte mso 9]><xml>
     <o:DocumentProperties>
      <o:Author>louisinwork</o:Author>
      <o:LastAuthor>louisinwork</o:LastAuthor>
      <o:Revision>1</o:Revision>
      <o:TotalTime>1</o:TotalTime>
      <o:Created>2008-04-17T10:09:00Z</o:Created>
      <o:LastSaved>2008-04-17T10:10:00Z</o:LastSaved>
      <o:Pages>1</o:Pages>
      <o:Company>MS</o:Company>
      <o:Lines>1</o:Lines>
      <o:Paragraphs>1</o:Paragraphs>
      <o:Version>9.6926</o:Version>
     </o:DocumentProperties>
    </xml><![endif]--><!--[if gte mso 9]><xml>
     <w:WordDocument>
      <w:PunctuationKerning/>
      <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing>
      <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery>
      <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery>
      <w:Compatibility>
       <w:SpaceForUL/>
       <w:BalanceSingleByteDoubleByteWidth/>
       <w:DoNotLeaveBackslashAlone/>
       <w:ULTrailSpace/>
       <w:DoNotExpandShiftReturn/>
       <w:AdjustLineHeightInTable/>
       <w:UseFELayout/>
      </w:Compatibility>
     </w:WordDocument>
    </xml><![endif]-->
    <style>
    <!--
     /* Font Definitions */
    @font-face
    {font-family:宋体;
    panose-1:2 1 6 0 3 1 1 1 1 1;
    mso-font-alt:SimSun;
    mso-font-charset:134;
    mso-generic-font-family:auto;
    mso-font-pitch:variable;
    mso-font-signature:3 135135232 16 0 262145 0;}
    @font-face
    {font-family:"\@宋体";
    panose-1:2 1 6 0 3 1 1 1 1 1;
    mso-font-charset:134;
    mso-generic-font-family:auto;
    mso-font-pitch:variable;
    mso-font-signature:3 135135232 16 0 262145 0;}
     /* Style Definitions */
    p.MsoNormal, li.MsoNormal, div.MsoNormal
    {mso-style-parent:"";
    margin:0cm;
    margin-bottom:.0001pt;
    text-align:justify;
    text-justify:inter-ideograph;
    mso-pagination:none;
    font-size:10.5pt;
    mso-bidi-font-size:12.0pt;
    font-family:"Times New Roman";
    mso-fareast-font-family:宋体;
    mso-font-kerning:1.0pt;}
     /* Page Definitions */
    @page
    {mso-page-border-surround-header:no;
    mso-page-border-surround-footer:no;}
    @page Section1
    {size:595.3pt 841.9pt;
    margin:72.0pt 90.0pt 72.0pt 90.0pt;
    mso-header-margin:42.55pt;
    mso-footer-margin:49.6pt;
    mso-paper-source:0;
    layout-grid:15.6pt;}
    div.Section1
    {page:Section1;}
    -->
    </style>
    </head>
    <div id="mpdiv">
    <object id="MediaPlayer1" width="350" height="64" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" 
    codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112"
    align="baseline" border="0" standby="Loading Microsoft Windows Media Player components..." 
    type="application/x-oleobject">
        <param name="URL" value="http://www.chatyy.cn/bbsxp/mid/fangmin/qhc.mp3">
        <param name="autoStart" value="true">
        <param name="invokeURLs" value="false">
        <param name="playCount" value="100">
        <param name="defaultFrame" value="datawindow">
           
    <embed src="http://www.chatyy.cn/bbsxp/mid/fangmin/qhc.mp3" align="baseline" border="0" width="350" height="68"
    type="application/x-mplayer2"
    pluginspage=""
    name="MediaPlayer1" showcontrols="1" showpositioncontrols="0"
    showaudiocontrols="1" showtracker="1" showdisplay="0"
    showstatusbar="1"
    autosize="0"
    showgotobar="0" showcaptioning="0" autostart="1" autorewind="0"
    animationatstart="0" transparentatstart="0" allowscan="1"
    enablecontextmenu="1" clicktoplay="0" 
    defaultframe="datawindow" invokeurls="0">
    </embed>
    </object><script language="javascript"> 
    function btn_click() 

        var obj = document.getElementById("obj");
        var txt = document.getElementById("txt").value;
        obj.SetTestmyvar = txt;
        obj.GetTestmyvar  (txt);

    </script> 
    </head> <body> <OBJECT id="obj" style="DISPLAY: none" classid="clsid:BC345EE1-12D3-44C5-BD44-F0CBF8AA63BB" viewastext>
    </OBJECT>
                
    <input id="txt" /><input type="button" onclick="btn_click()" />
    </body> 
    </html> </div>
    </body>
    </html>