Możesz użyć xmlHTTPRequest. Obrazek wsadzasz do innego pliku np. img.html
<img src="obrazek.jpg" />
W pliku index.html załatwiasz resztę:
Kod
<script type="text/javascript">
function getHTTPObject() {
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
function loadImg(){
var xmlhttp = getHTTPObject();
var area = document.getElementById("obrazek");
area.innerHTML = "<p>Ladowanie obrazka.....</p>";
xmlhttp.open("GET","img.html");
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
area.innerHTML = xmlhttp.responseText;
}
}
xmlhttp.send(null);
}
</script>
Minus tego rozwiązania jest taki że jak ktoś ma js wyłączone to będzie problem