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
  • 681
  • 1
  • 11
  • 33

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
  • 914,110
  • 126
  • 1,211
  • 1,335