Hello! There is a code that replaces the value in a specific block:

<a href="javascript:ReplaceContentInContainer('example1div','Home is clicked')"> 

Block:

  <div id="example1div" style=" padding:10px; text-align:center;"> Project Log </div> 

Script:

 <script type="text/javascript"> function ReplaceContentInContainer(id,content) { var container = document.getElementById(id); container.innerHTML = content; } </script> 

However, if you insert into the replacement (example1div) a picture, a tag img, then the code flies and something incomprehensible happens, for example:

 <img src="https://pp.vk.me/c543103/v543103564/1c7f0/Jkk_3iw_NFU.jpg" alt=""> 

That code flies. What is the problem? Thanks in advance for your help.

  • What does "code flies" mean? Just run your code - everything works. Give another example of the code calling the function - FeroxTL
  • codepen.io/Ants0li/pen/WxPNXB Here, on the second line, the code flies. - Deniss A.
  • Screen quotes. And put the question in order, give here (not on a third-party site) the minimum code that does not work. - FeroxTL
  • href="javascript:ReplaceContentInContainer('example1div','Home is clicked <br><br> <img src="https://pp.vk.me/c543103/v543103564/1c7f0/Jkk_3iw_NFU.jpg" alt="" width="300" height="300"> ')"> This line does not work correctly, although I tried to put quotes in several ways. - Deniss A.
  • Happened. Thank you all for your help. - Deniss A.

1 answer 1

Quotes in quotes in quotes. Probably, the html markup is not parsed correctly.

Read more in another answer .