I have the following HTML5 (only relevant):
<html>
<head>
<meta charset="UTF-8"/>
<title>Test</title>
</head>
<body>
<div id="layout">
<main>
<section>
<ul>
<li><img src="Imagens/Foto1.jpg" alt="" onclick="abrirFoto(this.src);"></li>
</ul>
</section>
</main>
</div>
<div id="overlay">
<div id="imgdiv"></div>
</div>
</body>
With the following JavaScript:
function abrirFoto(src) {
var divOpen = document.getElementById('overlay');
var openImg = document.createElement('IMG');
openImg.id = "open";
openImg.setAttribute('src',src);
imgDiv = document.getElementById('imgdiv');
divOpen.style.display = "block";
imgDiv.appendChild(openImg);
});}
It turns out that when JavaScript creates the image, the image comes with the src value as an absolute path, something I do not want to happen:
<div id="imgdiv">
<img id="open" src="file:///C:/Users/GustavoR/Desktop/HTML5/14.06%20N-Vermelho%20v2/Imagens/Foto3.jpg">
</div>
obs: I'm opening this site from a html file of my machine in the browser, FF 47.0.
When / Why does this occur? How to solve?