Skip to content

Instantly share code, notes, and snippets.

@itsdamslife
Created January 7, 2015 10:23
Show Gist options
  • Save itsdamslife/03cde0577345ef2db02a to your computer and use it in GitHub Desktop.
Save itsdamslife/03cde0577345ef2db02a to your computer and use it in GitHub Desktop.
Simple HTML-JS code. Takes server address as input constructs a path and auto-refreshes the image every second. Just for personal reference.
<html>
<script>
var index = 0;
function connect()
{
var addr = document.getElementById("address")
var imgPath = "http://" + addr.value + ":8080/Test.png";
document.getElementById("path").innerHTML = imgPath;
setInterval(function() {
index = index + 1;
document.getElementById("refreshCounter").innerHTML = "Refreshed " + index + " times";
document.getElementById("image").src = imgPath+"?time="+(new Date().getTime());
}, 1000);
}
</script>
<body>
<br><br>
<p>Enter the address:
<input id="address" type="text" name="fname">
<button type="button" onclick="connect()">Connect!</button></p><br>
<p>Path accessed: <label id="path">/this/is/a/path</label></p><br>
<img id="image" src="" alt="Image not found" height="120" width="300">
<br><p id="refreshCounter">Refreshed 0 times</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment