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

155
Views
how to get image src if it is in binary on mobile phones

i am creating qr codes using This Libary and this is how it works, it creates an image tag and stores the qr code image in the src as a binary image. i want to download the qr code image, it works perfectly on my laptop but when i tested it on my mobile phone it didn't work, i even tried to alert the src of the image but it came out empty, how can i solve this? here is my code:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>qrcode</title>

  <style>
    #qrcode {
      width: 160px;
      height: 160px;
      margin-top: 15px;
    }
  </style>
</head>

<body>
  <input type="button" id="cmd" value="Save PNG" onclick="saveimg()" />
  <a href="" download="ConferPressQrTicket" id="download">download</a>

  <div id="qrcode"></div>
  <script src="./qrcode.min.js"></script>

  <script type="text/javascript">
    // var qrcode = new QRCode("qrcode");
    var qrcode = new QRCode("qrcode", {
    text: "",
    width: 200,
    height: 200,
    colorDark : "#000",
    colorLight : "#ffffff",
    correctLevel : QRCode.CorrectLevel.H
});

    function makeCode() {
      let TickectId = location.href.split("=")[1];
      let dfd = qrcode.makeCode("TickectId")

    }

    function saveimg() {
      alert(document.getElementsByTagName("img")[0].src)
      document.getElementById("download").href = document.getElementsByTagName("img")[0].src;
    }
    makeCode();
    document.getElementById("cmd").addEventListener("click", () => {
      alert(document.getElementsByTagName("img")[0].src)
      document.getElementById("download").href = document.getElementsByTagName("img")[0].src;
    })

  </script>
</body>

</html>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

add this to your code

var can = document.querySelector("#qrcode canvas");
alert(can.toDataURL())
document.getElementById("download").href = can.toDataURL();
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!