3
I tried to upload image by JS
but I couldn’t do it through onload
, follows the code I tried:
HTML:
<img class="razer" id="imageoption" onload="imageOption()">
JS:
document.onload = function imageOption() {
document.getElementById("imageoption").src = "images/hyperx-option.png"; }
I don’t understand what you want, the way it is
src="images/hyperx-option.png"
directly ontag
. You can explain better what you want to do?– Caique Romero
So, this page will have several tags depending on the option chosen in the previous page this carries a different mark, I was trying to hit this part of js with html but I could not make the image appear.
– Ahri Main
You don’t need javascript for this, try it like this:
<img class="razer" id="imageoption" src="images/hyperx-option.png">
– Caique Romero
So it works perfectly, but when I access this same page with another previous option I want another image to appear
– Ahri Main
I think I’m beginning to understand your question, how does the new page identify which image to display? If you are browsing from one page to another you can pass data in case the
src
through theurl
or a form. What programming language are you using? Have you researched aboutGET/POST
– Caique Romero