Hi everyone,
I have preloaded the images and then view the bigger image in a new window.
I have a page with number of images and on a image click, I call function PopImage('imagename'). The problem is that if I have clicked on an image and viewd it in a new window and that window is still open and then I try to view another image, it will keep on poping up the first image. So image doesn't get refreshed. This is my javascript code below:
<script>
var myImage;
var wd,img,hi,opWin=0,imgWindow
function PopImage(img) {
myImage = new Image()
myImage.src = img
IsLoaded(img)
}
function IsLoaded(img) {
if (myImage.complete){
var wd = myImage.width
var hi = myImage.height
var imgWindow=window.open ('', 'img_window', 'scrollbars=no,status=no,resizable=no,width='+wd+',height='+hi+'')
imgWindow.document.writeln(
'<style>body{border:0;margin-width:0;padding:0;}</style><body bgcolor="##ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">'
+'<img src="'+img+'" width=100% height=100%></body>');
imgWindow.focus();
opWin++
self.status = 'Image Loaded!'
setTimeout('self.status = \'\'',2000)
}
else {
setTimeout('IsLoaded(\''+img+'\')',100)
self.status = 'Loading Image - '+img+'....'
}
}
</script>
Any help is appreciated.
Thanks
I have preloaded the images and then view the bigger image in a new window.
I have a page with number of images and on a image click, I call function PopImage('imagename'). The problem is that if I have clicked on an image and viewd it in a new window and that window is still open and then I try to view another image, it will keep on poping up the first image. So image doesn't get refreshed. This is my javascript code below:
<script>
var myImage;
var wd,img,hi,opWin=0,imgWindow
function PopImage(img) {
myImage = new Image()
myImage.src = img
IsLoaded(img)
}
function IsLoaded(img) {
if (myImage.complete){
var wd = myImage.width
var hi = myImage.height
var imgWindow=window.open ('', 'img_window', 'scrollbars=no,status=no,resizable=no,width='+wd+',height='+hi+'')
imgWindow.document.writeln(
'<style>body{border:0;margin-width:0;padding:0;}</style><body bgcolor="##ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">'
+'<img src="'+img+'" width=100% height=100%></body>');
imgWindow.focus();
opWin++
self.status = 'Image Loaded!'
setTimeout('self.status = \'\'',2000)
}
else {
setTimeout('IsLoaded(\''+img+'\')',100)
self.status = 'Loading Image - '+img+'....'
}
}
</script>
Any help is appreciated.
Thanks