You must Sign In to post a response.
  • Category: JavaScript

    Copy from clipboard is not working in Firefox

    HI all,

    The below code is working in IE and Chrome,please assist me to fix the same in firefox.

    var clipData = window.clipboardData.getData('Text'); // working perfect in IE
    var clipData = event.clipboardData.getData('Text'); // working perfect in chrome


    Thanks in Advance.
  • #758982
    Hello Vijai,

    Refer the below example :

    <script>
    function fnBeforePaste() {
    event.returnValue = false;
    }
    // Cancel the returnValue in onpaste for the text input, which
    // has a default behavior.
    function fnPaste() {
    event.returnValue = false;
    oTarget.innerText = window.clipboardData.getData("Text");
    }
    </script>

    <div class="clsTarget" ID="oTarget" onbeforepaste="fnBeforePaste()" onpaste="fnPaste()">
    Paste the Text Here
    </div>

    Hope this will help you.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "If you can dream it, you can do it."

  • #758984
    Hi Nirav,

    Thanks for you support.

    I tried the above code.again it's working perfectly in IE ,Chrome not in firefox.

    I beleive the syntax

    window.clipboardData.getData("Text"); is not supported by firefox.

    Thanks & Regards,
    Vijai M

  • #758986
    Hi Vijai.

    Script is on or turned off in firefox check once as it is working in IE and Chrome why not in firefox.

    Try to check with different browser like on opera.
    If still problem persists then there might be problem with in the browser.

    Regards

    Sridhar.
    DNS Member.
    "Hope for the best.. prepare for the worst.."

    Sridhar Thota.
    Editor: DNS Forum.

  • #759016
    There is slight change in firefox for copying clipboard data, you need to use 'Clipboard.clipboardData' , it works on firefox version 22 and above
    OR you can use following method in firefox
    Services.clipboard.getData(trans, Services.clipboard.kGlobalClipboard);

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]


  • Sign In to post your comments