1

i am trying to put a variable using script on an image url but it does not seem to work instead the url display the encoded text

<img src="<script type="text/javascript">document.write(image_one);</script>" 
JeVic
  • 671
  • 9
  • 30

1 Answers1

2

You can't put an element inside an attribute value.

You can either generate the entire element from JavaScript, or you can create it with a default value for the src and then use DOM to change the src to something else.

Quentin
  • 800,325
  • 104
  • 1,079
  • 1,205