javascript操作粘贴板

<body MS_POSITIONING="GridLayout">
        
<script type="text/javascript"> 
   
<!-- 
   
function clip(text){   
   
//str=eval("document.getElementById('copy1')"); 
   //str.select(); 
   //str = document.selection.createRange(); 
   //clipboardData.setData('text',(str.text)); 
   var sel = document.body.createTextRange();
            sel.moveToElementText(document.getElementById(
'copy'));//此处form是页面form的id
            sel.select();
            sel.execCommand(
"Copy");
   }
 
   
//--> 
        
</script>
        
<form id="Form1" method="post" runat="server">
            
<href="javascript:clip()">复制到剪贴板</a><br>
            
&nbsp;
            
<asp:Label id="copy" style="Z-INDEX: 102; LEFT: 48px; POSITION: absolute; TOP: 96px" runat="server">2<sup>
                    2
</sup></asp:Label>
        
</form>
    
</body>
1.首先用后台语言从数据库里读取数据
2.把从数据库里读取到的数据用javascript操作付到页面中去。
eg:
function replaceDate()
            
{                
                
if(isNewSign=="none")
                
{                                
                    
if(TANGER_OCX_OBJ!="")
                    
{
                        var myDocApp
=TANGER_OCX_OBJ;                    
                        
//****************Word替换文字型窗体区域书签内容*******************
                        
//只能替换一次                    
                        myDocApp.ActiveDocument.FormFields("recfilecode").Range = recfilecode;             
                        myDocApp.ActiveDocument.FormFields(
"recfileno").Range = recfileno;
                        myDocApp.ActiveDocument.FormFields(
"recfilemj").Range = recfilemj;
                        myDocApp.ActiveDocument.FormFields(
"recfileyear").Range = recfileyear;
                        myDocApp.ActiveDocument.FormFields(
"recfilemonth").Range = recfilemonth;
                        myDocApp.ActiveDocument.FormFields(
"recfileday").Range = recfileday;
                        myDocApp.ActiveDocument.FormFields(
"recfiletitle").Range = recfiletitle;
                        myDocApp.ActiveDocument.FormFields(
"recfileunite").Range = recfileunite;
                        
                    
                }

            }
说明:1)FormFields是word中的属性,
2)ActiveDocument(NTKO中的属性):返回文档对象的自动化接口
3)("recfilecode")为word摸板中的字段名 
posted @ 2008-04-02 17:44  你约我交友网  阅读(1478)  评论(0编辑  收藏  举报