When playing code from the Brackets editor, everything works, functions are called.
But if you try to open index.html in the browser and trigger an event, the browser reports an error - the function was not found. What I just did not try and what info I didn’t put into script tags - nothing helps, only Yandex works, all other browsers do not see the function or scripts.
Code:
function img_up(arg_src){ var div_all = document.createElement('div'); div_all.id="div_all_id"; document.body.appendChild(div_all); var div_tx = document.createElement('div'); div_tx.id="div_image"; document.body.appendChild(div_tx); div_tx.innerHTML="<img src="+" ' "+arg_src+" ' "+" onclick='img_dw()' >"; } function img_dw(){ var remel=document.getElementById("div_image"); remel.parentNode.removeChild(remel); var rem_ove=document.getElementById("div_all_id"); rem_ove.parentNode.removeChild(rem_ove); } #div_all_id{ position:fixed; width: 100%; height: 100%; background: black; opacity: 0.7; } #div_image{ position:fixed; background: black; color: red; } #div_image img{ position:fixed; padding-left: 10%; padding-right: 10%; padding-top: 5%; width: 80%; } #galary{ position: absolute; } #galary img{ width: 200px; } <html> <head> <link rel="stylesheet" href="galary.css" type="text/css" media="screen"> <script type="text/javascript" src="galaryjs.js"></script> </head> <body> <div id="galary"> <img src="1.jpg" onClick="img_up(src)" > <img src="2.jpg" onClick="img_up(src)" > </div> </body> </html>
body. Or use the eventDOMContentLoaded/window.loaded- Mr. Blackonclick='img_up(this.src);'so more correct. And more advice, do not use any programs for writing code that does not require compilation. It will be enough to text editorSublime TextorNotepad++- Mr. Black