472,780 Members | 1,169 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 software developers and data experts.

IE.6 shows blank images sporadically

Hey All,

I am new to javascript and currently coding a site with scripts that
are beyond my level of understanding. The problematic page has
thumbnail images that can be clicked on to zoom in. When clicked, the
preloaded larger image displays in a div layer that gets turned on. The
problem is that ie sometimes does not display the image - the
placeholder just stays blank. The script works fine in firefox and
netscape (haven't tried safari yet). Since I am new to this and this
only happens sporadically, I'm having a lot of trouble identifying the
error or a fix. Also, the src for the images is dynamically created
from the text name that displays below the bags. This is for content
management purposes. Any suggestions you can give would be much
appreciated.

Thanks,

Trent

Here is the link: www.woundedmouse.com/pearson/showroom.html

Here is the pertinent code:

<SCRIPT TYPE="text/javascript">

var nextzoom = 'next'
var prezoom = 'pre'

//Change the name of the bags below. Ex: Replace "Tina 1II" with "Tina
3". Don't forget the quotes.//
var text = new Array (12)
text[0] = "Tina 1II"
text[1] = "Wendy 4F"
text[2] = "Peggy 1T"
text[3] = "Sarah 1E"
text[4] = "Kimberly 4T"
text[5] = "Kimberly 1U"
text[6] = "Kate 1QQ"
text[7] = "Julie 4W"
text[8] = "Julie 1S"
text[9] = "Julie 1J"
text[10] = "Grace 1GG"
text[11] = "Audrey 1SS"

var smbags = new Array (12)

var zoombag = new Array (12)

//displays the text for each bag name
function bagtext(num)
{
return text[num]
}

//splits the name of the bag, appends info, and writes to array
function splitsm(num)
{
for (num=num; num < 12; num++)
{
var x = text[num];
var change = x.toLowerCase();
var temp = new Array();
temp = change.split(' ');
var y = 'images/' +temp[0] + temp[1] + '.jpg';
var z = 'images/' +temp[0] + temp[1] + '_zoom.jpg';
smbags[num] = new Image();
smbags[num].src = y;
window.top.smbags[num] = y;
var zoomtemp = new Array();
zoomtemp[num] = new Image();
zoomtemp[num].src = z;
window.top.zoombag[num] = z;
}

}

//zoom bag preloader
function preloadzoom(){
for (i=0; i<12;i++)
{
zoombag[i]=new Image();
}
//alert(zoombag);
}

//loads small bags in placeholders once their src is identified
function loadbag(num)
{
for (num=num; num <12; num++)
document['slot' +num].src = smbags[num]
//alert(zoombag);

}

//loads larger zoom image into placeholder
function loadzoom(num)
{
document.zoom.src = zoombag[num]
window.top.nextzoom = num+1;
window.top.prezoom = num-1;
}

//turns on div layer that contains zoom placeholder
function bagshow()
{
if(document.layers){
//thisbrowser="NN4";
document.bag.visibility="visible";
}
if(document.all){
//thisbrowser="ie"
document.all.bag.style.visibility="visible";
}
if(!document.all && document.getElementById){
//thisbrowser="NN6";
document.getElementById("bag").style.visibility="v isible";

}
}

//turns off div layer that contains zoom placeholder
function baghide()
{
if(document.layers){
//thisbrowser="NN4";
document.bag.visibility="hidden";
}
if(document.all){
//thisbrowser="ie"
document.all.bag.style.visibility="hidden";
}
if(!document.all && document.getElementById){
//thisbrowser="NN6";
document.getElementById("bag").style.visibility="h idden";

}
}

function newImage(arg) {
if (document.images) {
rslt = new Image();
rslt.src = arg;
return rslt;
}
}

function changeImages() {
if (document.images && (preloadFlag == true)) {
for (var i=0; i<changeImages.arguments.length; i+=2) {
document[changeImages.arguments[i]].src =
changeImages.arguments[i+1];
}
}
}

var preloadFlag = false;
function preloadImages() {
if (document.images) {
about_over = newImage("images/about-over.gif");
styles_over = newImage("images/styles-over.gif");
fabrics_over = newImage("images/fabrics-over.gif");
contact_over = newImage("images/contact-over.gif");
preloadFlag = true;
}
}

// -->
</SCRIPT>
<!-- End Preload Script -->
<link rel="stylesheet" type="text/css" href="master.css">
</HEAD>
<BODY onload="preloadzoom(); splitsm(0); loadbag(0); preloadImages(); "
BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0
background="images/bck01.gif">
<div id="bag" style="width: 100%; height: 100%; visibility:hidden;
position:absolute; left:0px; top:0px" >
<table width="100%" height="100%" valign="middle">
<tr>
<td>
<div align="center">
<table class="bag" bgcolor="white" width="360" height="490">
<tr height="10" valign="middle">
<td style="text-align: center" width="165">
<a class="fbags" href="javascript:void(0)"
onclick="loadzoom(prezoom);">< Pre</a>
</td>
<td style="text-align: center" width="165">

<a class="fbags" href="javascript:void(0)"
onclick="loadzoom(nextzoom);"> Next ></a>
</td>
<td style="text-align: center" width="30">
<a class="fbags" href="javascript:void(0)"
onclick="baghide();">[x]</a></td>
</tr>
<tr height="480">
<td colspan="3" ><img name="zoom" border="0"
src="images/spacer.gif" width="360" height="480">
</td>
</tr>
</table>
</div>
</td>
</tr>
</table></div>

Jul 23 '05 #1
2 1854
I've tried your page in Firefox and IE6 ... Firefox works fine, but in
IE6 some bags don't show up at all in the zoom (particulary the first
6 bags at the top), some bags sometimes show up partly in the zoom
(after some more clicking these bags show up completely) and some bags
always show up completely (particularly the bags at the bottom).

I did find one thing that doesn't look right in your code:

In the splitsm function you preload the smbags images array (works
OK), and you preload the zoomtemp images array (why zoomTEMP and not
zoomBAG?). The preloadzoom function doesn't do any preloading at all
(it just creates an array with empty images)

So, to make it work properly you could:

- change these lines ...
var zoomtemp = new Array();
zoomtemp[num] = new Image();
zoomtemp[num].src = z;
....to
zoombag = new Array();
zoombag[num] = new Image();
zoombag[num].src = z;

- kill the preloadzoom function (it doesn't do anything; don't forget
to remove it from the body onload event too!)

I'm also wondering what these lines should do:
-> window.top.smbags[num] = y;
-> window.top.zoombag[num] = z;

As far as I can tell these lines can be safely removed too.

Oh, and there's a small bug in your loadzoom function:

What if somebody zoomed in on the first image and pressed the Prev
link (or zoomed in on the last image and pressed the Next link)?

To avoid these situations change the code as follows:

function loadzoom(num)
{
// check if there is a next image, if not use the first image
var next = (num < (zoombag.length - 1) ? (num + 1) : 0);
// check if there is a prev image, if not use the last image
var prev = (num > 0 ? (num - 1) : (zoombag.length - 1));

document.zoom.src = zoombag[num]
window.top.nextzoom = next;
window.top.prezoom = prev;
}

This will link the first Prev to the last image and the last Next to
the first image (this could also be done by using if { .. }
statements, the (A ? B : C) is just shorthand for if A (is true) then
B else C.

The first line could also be written as
if (num < zoombag.length - 1)
var next = num + 1;
else
var next = 0;

Last (but not least) the loop you use in the splitsm function should
be written as

for (num = 0; num < 12; num++)

(start with num at 0 and loop until num is 12 or more)
Nice website by the way!
Kind regards,

Jeroen Brattinga
Trent wrote:
Hey All,

I am new to javascript and currently coding a site with scripts that
are beyond my level of understanding. The problematic page has
thumbnail images that can be clicked on to zoom in. When clicked, the
preloaded larger image displays in a div layer that gets turned on. The
problem is that ie sometimes does not display the image - the
placeholder just stays blank. The script works fine in firefox and
netscape (haven't tried safari yet). Since I am new to this and this
only happens sporadically, I'm having a lot of trouble identifying the
error or a fix. Also, the src for the images is dynamically created
from the text name that displays below the bags. This is for content
management purposes. Any suggestions you can give would be much
appreciated.

Thanks,

Trent

Here is the link: www.woundedmouse.com/pearson/showroom.html

Here is the pertinent code:

<SCRIPT TYPE="text/javascript">
/* SNIP */

Jul 23 '05 #2
Thanks for the reply Jeroen - I really appreciate your help. I'll let
you know the outcome.

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jon Glazer | last post by:
I have a small function that simply swaps image A with image B. The problem is that in some situations (i don't know why yet) when A and B are swapped, they simply vanish. Here is the function...
6
by: Dan | last post by:
I've created a pocketpc app which has a startup form containing a listview. The form creates an object which in turn creates a System.Threading.Timer. It keeps track of the Timer state using a...
7
by: Jacob | last post by:
Has anybody else encountered a problem when running your asp.net applications off your localhost and having broken image links? The weird thing is, the links aren't really broken. The reference...
4
by: MVSGuy | last post by:
Hello, I have a problem where a Notes field shows up in Access (via ODBC connection) but the value is either zero or blank in Access. I've verified the field is not zero or blank in Notes. ...
2
by: eBob.com | last post by:
I have a print application modeled on a program which I found via this newsgroup. (I still have comments in German in it!) The model uses ExtendedPrintPreviewDialog but I don't seem to have that...
1
by: dr1ft3r | last post by:
I, like many others, hate IE simply because it doesn't go along with standard and bothers every site anybody attempted to make in the history of the web. I've checked this site in FF, NS, and Opera...
8
by: jonmundsack | last post by:
I have an intranet site on my LAN which has "anonymous access" turned OFF, and "integrated Windows authentication" turned on. This allows me to access the "AUTH_USER" server variable, which I use...
3
by: simon2x1 | last post by:
the code below will upload image and insert the image name and other variable into the database but i dont want the upload feild to post a blank field and also not to allow any image which is not...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.