Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

260
Visualizações
HTML how to get canvas resource file?

The picture on the HTML page is represented as a canvas, but I have problems getting the source image name of this canvas, using javascript.

enter image description here

Page: https://www.futbin.com/22/squad-builder

I found this image in the page resources: enter image description here

But how to get it programmically? I mean, if i have:

var canvas = document.getElementById('field-area')

How to get the file name? Result should be "field_1920x1080.png?v=8"

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can use HTMLCanvasElement.toDataURL to get the image drawn on the canvas base64 encoded

var canvas = document.getElementById('field-area');
var b64url = canvas.toDataURL('image/png');

This will return the url for the image itself, i don't think you can get the Asset name directly from a canvas element without inspecting the code on the website

about 4 years ago · Juan Pablo Isaza Relatório

0

EJBEAN is right, the canvas element doesn't know what resources were used to draw.

Why don't you use dataset to keep an eye on what you used?

var canvas = document.getElementById('field-area');
// ... draw resource here
canvas.dataset.resource = "field_1920x1080.png";

It's an easy way to keep data stored for any element on your page.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda