section31
07-14-2005, 03:36 PM
Ok, this is a long shot but I hope someone can help me. I'm receiving a javascript error on IE, but not on firefox and the line number returned on ie is just the declaration for javascript so I don't know whats wrong. The thing that makes this even more confusing is that the error only happens when the image is stored in the cache. When you ctrl+refresh bypassing the cache, the image and function loads fine, but when you load the image from the cache, the function goofs up and ie returns an error "object required"
Can someone take a look at this and tell me if you see something wrong.
see script in action here (http://www.onivertneb.com/chics/file/section31/Jennifer%20Love%20Hewitt/Jennifer%20Love%20Hewitt%204.jpg)
<script type="text/javascript">
var x = new Image;
x.src = 'foobar.jpg';
loading = setTimeout("scaleImg()", 200);
var saveWidth = 0;
function scaleImg()
{
if (x.complete) {
what = document.getElementById('thepic');
if (winW = screen.width) {
if (what.width>(winW-100) || saveWidth>(winW-100)) {
if (what.width == (winW-100)) {
what.width = saveWidth;
}
else {
saveWidth = what.width;
what.width = (winW-100);
}
}
}
clearTimeout(loading);
}
else {
loading = setTimeout("scaleImg()", 200);
}
}
</script>
What I'm doing here is using the image object to determine when the image is complete, and when its complete I have it resize to a suitable width for the clients screen size. It works fine on both ie and mozilla when the image is not in the cache which is ok, but my main riority is getting rid of that error that I get on ie when I refresh the document.
Can someone take a look at this and tell me if you see something wrong.
see script in action here (http://www.onivertneb.com/chics/file/section31/Jennifer%20Love%20Hewitt/Jennifer%20Love%20Hewitt%204.jpg)
<script type="text/javascript">
var x = new Image;
x.src = 'foobar.jpg';
loading = setTimeout("scaleImg()", 200);
var saveWidth = 0;
function scaleImg()
{
if (x.complete) {
what = document.getElementById('thepic');
if (winW = screen.width) {
if (what.width>(winW-100) || saveWidth>(winW-100)) {
if (what.width == (winW-100)) {
what.width = saveWidth;
}
else {
saveWidth = what.width;
what.width = (winW-100);
}
}
}
clearTimeout(loading);
}
else {
loading = setTimeout("scaleImg()", 200);
}
}
</script>
What I'm doing here is using the image object to determine when the image is complete, and when its complete I have it resize to a suitable width for the clients screen size. It works fine on both ie and mozilla when the image is not in the cache which is ok, but my main riority is getting rid of that error that I get on ie when I refresh the document.