Skip to content

img src is empty and canvas is visible on Android #287

Open
@akinuri

Description

I see that the QR code is generated on canvas, and then copied to an img element using base64 and the canvas is hidden.

This process does not seem to work properly on Android. The canvas is visible (but should be hidden), and the src attribute of the img is empty, which gives the impression that the image is hidden. However, it works as expected on iOS.

Tested this on the following devices/browsers:

  • Android
    • Samsung M31
      • Samsung Internet 19.0.6.3
      • Chrome 108.0.5359
    • Xiaomi Mi 6
      • Browser V11.1.9-g
      • Chrome 108.0.5359
  • iOS
    • iPhone 13 Pro
      • Safari (iOS 16.1.1)
      • Chrome 108.0.5359

I had to figure out a way to show the QR (and style the canvas and the image the same) on both desktop and mobile.

The code I used to test this out:

<style>
    #qrcode canvas { border: 5px solid red; }
    #qrcode img    { border: 5px solid limegreen; }
</style>

<div id="qrcode"></div>

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

<script type="text/javascript">
new QRCode(document.getElementById("qrcode"), "http://jindo.dev.naver.com/collie");
</script>

On desktop, I see the green one. On mobile, it's the red one.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions