1

I wish to find out if I can achieve that img or input HTML can use image object data present in JavaScript variable.

<input class="scroll" type="image" id="SCR_BoostWeapon" src="" title="Increase your sword skill" />
$("#SCR_BoostWeapon").attr("src", SPRITE.SCR_BoostWeapon.src);

I can link the source of image in <input> to image object SPRITE.SCR_BoostWeapon, which was preloaded. However I can only link src property of the image object to src property of input element. Consequently, the browser loads the image again (from server or cache).

What I would like to achieve is to manipulate input or img HTML element to use image data already present in image object; not src but rather 'pointer' to image data.

Is this possible? If it is, how?

Lovro
  • 185
  • 1
  • 3
  • 12
  • `SPRITE.SCR_BoostWeapon.src` debug it and check value of it. also input does not have `src` attribute `img` have and `src` attribute – Devsi Odedra Aug 02 '19 at 13:34
  • @DevsiOdedra; I know the value of it. It's address. I can use it as src of img element. But that was not the question. – Lovro Aug 02 '19 at 13:36
  • @DevsiOdedra `input type="image"` elements do have a `src` attribute: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/image, although it's *very* outdated. – Rory McCrossan Aug 02 '19 at 13:37
  • @DevsiOdedra; has src attribute. – Lovro Aug 02 '19 at 13:38
  • simply, there is no concept of pointing an attribute value to an another tag's attribute - HTML do not behave like other programming. but take a lookhttps://stackoverflow.com/questions/11271484/when-multiple-instances-of-same-images-are-embedded-in-an-html-does-that-load-t to know how image is re-used in HTML – Garfield Aug 02 '19 at 13:48
  • @Garfield; thanks: I have set the cache. It bothers me that I can't do it more directly. – Lovro Aug 02 '19 at 13:56

0 Answers0