I have the following script that is not giving me the result I want. JSFiddle link at the bottom.
Note: This is not my image. I grabbed it randomly from imgur.
I expect:
<img src="https://i.imgur.com/MiOeWrk.jpg" style="max-width:800px;">
But I get this, I believe, but I'm unable to write this in a code block while debugging, for some reason.
<img src="http://thisismydomain.com/https://i.imgur.com/MiOeWrk.jpg" style="max-width:800px;">
Here's my script. Please advise:
<div><a href="javascript:viewimage('https://i.imgur.com/MiOeWrk.jpg','video_aba');">Show Image</a></div>
<div id="jsdebug">jsdebug</div>
<div id="video_aba">video_aba</div>
<script>
function viewimage(ytlink, uid) {
var imagelink = ytlink;
document.getElementById("jsdebug").innerHTML = imagelink;
var uid = uid;
if (imagelink.length == 0) {
imageembed = "<strong>Sorry, unable to load.</strong>";
} else {
imageembed = "<img src=\"/" + imagelink + "\" style=\"max-width:800px\">";
}
document.getElementById("video_aba").innerHTML = imageembed;
}
</script>