Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
Copy to clipboard is worked fine on PC but not works on Android device

My approach of copy to clipboard works fine on pc but has not worked on android. I tried on chrome(latest version) on my Samsung galaxy s20fe android version 12

<button onClick={() => handleCopy()}>Copy</button>
const clipboardData = `Name: ${modalData.name}
   Department: ${modalData.department}
   Batch: ${modalData.batch}
   BG: ${modalData.bg}
   Phone: ${modalData.phone}`;

    const handleCopy = () => {
        navigator.clipboard
            .writeText(clipboardData)
            .then(() => {
                alert('successfully copied');
            })
            .catch(() => {
                alert('something went wrong');
            });
      alert('๐Ÿ“‹ Coppied to clipboard!');
    };
about 4 years ago ยท Juan Pablo Isaza
1 answers
Answer question

0

Accroding to mdn documentation

The asynchronous clipboard API is a relatively recent addition, and the process of implementing it in browsers is not yet complete. Due to both potential security concerns and technical complexities, the process of integrating this API is happening gradually in most browsers.

So you can try this:

    const handleCopy= () => {
        const element = document.createElement("textarea");
        element.value = clipboardData;
        document.body.appendChild(element)
        element.select();
        document.execCommand("copy");
        document.body.removeChild(element);
        alert('๐Ÿ“‹ Coppied to clipboard!');
    }

about 4 years ago ยท Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!