PDA

View Full Version : code breaks Mac IE5.5 and PC IE 5


trikota
10-07-2002, 07:42 PM
This is the code for the page.
It works fine on Netscape 4.7 and IE 6. But not on Mac IE5.5 and PC IE5. I don't kow what it is. Please, help.

<html>
<head>
<title>title</title>

<script><!--
var imageData = [
['empa_fullquote01.jpg','empa_quote01.jpg','280','540'],
['empa_fullquote02.jpg','empa_quote02.jpg','280','485'],
['empa_fullquote03.jpg','empa_quote03.jpg','280','474'],
['empa_fullquote04.jpg','empa_quote04.jpg','280','540'],
['empa_fullquote05.jpg','empa_quote05.jpg','280','540'],
];
var imgRoot = "images/";
var picked = new Array();
for (var i=0; i<imageData.length-1; picked.push(0), i++);

function showPopup(i) {
var f = 'width=' + imageData[i][2] + ',height=' + imageData[i][3];
window.open(imgRoot+imageData[i][0],'picWin', f);
}

function insertRandomImgs(qty) {
var p = 0;
while (p < qty) {
var i = Math.floor(Math.random() * imageData.length);
if (picked[i] == 0) {
document.write('<a href="#" onClick="showPopup('+i+'); return false"><img src="'+imgRoot+imageData[i][1]+'" style="cursor:hand" alt="'+imageData[i][0]+'" border=0></a>');
picked[i] = 1;
p++;
}
}
}
// -->
</script>

</head>

<body>
<script>
insertRandomImgs(1);
</script>

</body>
</html>

Catman
10-07-2002, 10:30 PM
I'm guessing you need to write var imgRoot = "images/"; as var imgRoot = "images\/"; and </a> as <\/a>.

ahosang
10-07-2002, 11:27 PM
It's the push function which is not supported until IE 5.5, but was supported by Netscape 4.x
Instead use:
arr[arr.length]=yourValue;
instead of:
arr.push(yourValue);

Owl
10-08-2002, 01:26 AM
http://www.codingforums.com/showthread.php?s=&postid=31567#post31567

( •) (• )
>>V

realisis
10-08-2002, 05:39 AM
trikota: why start a new thread when you could easily have continued the existing one?

And why are you still using the same problem-statements as in the original script/thread when those points have already been discussed? Eg: push()

trikota
10-08-2002, 06:57 AM
I am sorry I started a new one. Didn't think.
About the push()... I thought that with a different use of push I can use it. Obviously I was wrong.

trikota
10-08-2002, 07:17 PM
Ok, so I panicked before and stopped thinking...
When I replace push command with picked[i]=0 the code works great on all platforms.