【问题标题】:paste functionality in google chrome and safarigoogle chrome 和 safari 中的粘贴功能
【发布时间】:2011-03-19 07:14:54
【问题描述】:

我无法将内容粘贴到属性“Textmode”为多行的文本框中,此问题发生在 google chrome 和 safari 浏览器中

【问题讨论】:

    标签: c# asp.net browser google-chrome safari


    【解决方案1】:

    为了安全起见,使用ZeroClipboard 实现剪贴板功能,适用于所有浏览器,与任何浏览器复制粘贴功能无关。

    请参阅下面的用法。在您的项目中下载并解压 Zeroclipboard

    <script src="zeroclipboard/ZeroClipboard.js" type="text/javascript"></script>
      <script type="text/javascript" >
          ZeroClipboard.setMoviePath('zeroclipboard/ZeroClipboard.swf');
         <script language="JavaScript" type="text/javascript">
                var clip = null;
    
    
                function init() {
                    clip = new ZeroClipboard.Client();
                    clip.setHandCursor(true);
    
                    clip.addEventListener('load', function(client) {
                    });
    
                    clip.addEventListener('mouseOver', function(client) {
                        // update the text on mouse over
                        clip.setText(document.getElementById('TextBox1').value);
                    });
    
                    clip.addEventListener('complete', function(client, text) {
    
                    Label1.innerText = document.getElementById('TextBox1').value + ' Copied to clipboard.';
                    });
    
                    clip.glue('divbutton', 'divcontainer');
                }
    
    
            </script>
    
    1. Don't forget to set <body onLoad="init()">
    2. Set the clip.SetText method in onchnage event of the textbox. <td align="left">
                                <asp:TextBox ID="TextBox1" runat="server" Width="218px" onchange="clip.setText(this.value)"></asp:TextBox>
                            </td>
    3. <div id="divcontainer" style="position: relative; top: 0px; left: 0px; width: 193px;">
                        <div id="divbutton" class="mybutton">
                            <b>Copy To Clipboard...</b></div>
                    </div> in case use need to some button's illusion on page.
    

    【讨论】:

    • - 谢谢回复,我正在处理,有没有其他可能的方法让这件事发生
    猜你喜欢
    • 2011-09-14
    • 2011-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-07
    • 2016-11-27
    相关资源
    最近更新 更多