PDA

View Full Version : javascript not worked in IE.



j_admin
03-20-2010, 11:28 AM
I write javascript for image slide show.



var mygallery=new fadeSlideShow({
wrapperid: "fadeshow1", //ID of blank DIV on page to house Slideshow
dimensions: [380, 469], //width/height of gallery in pixels. Should reflect dimensions of largest image
imagearray: [
<?php $q2 = mysql_query("select * from home_flash");
$i = 0;
while($res = mysql_fetch_array($q2))
{
$image[$i] = $res[1];
$text[$i] = $res[2];
$str = "['images/fla/".$image[$i]."','','','".$text[$i]."'],";
echo $str;
$i++;
} ?>

//<--no trailing comma after very last image element!
],
displaymode: {type:'auto', pause:2500, cycles:0, wraparound:false},
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
descreveal: "always",
togglerid: ""
})


In IE I got an error


Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; InfoPath.2)
Timestamp: Sat, 20 Mar 2010 06:22:10 UTC

Message: 'imagearray[...].0' is null or not an object
Line: 37
Char: 3
Code: 0

If you have solution for thi, then please help with it!

Thanks for your precious time.

Cheers!!

jscheuer1
03-20-2010, 04:05 PM
The problem is that there can be no trailing comma after the last entry in the imagearray. Here's one way to avoid that:


var mygallery = {
wrapperid: "fadeshow1", //ID of blank DIV on page to house Slideshow
dimensions: [380, 469], //width/height of gallery in pixels. Should reflect dimensions of largest image
imagearray: [
<?php $q2 = mysql_query("select * from home_flash");
$i = 0;
while($res = mysql_fetch_array($q2))
{
$image[$i] = $res[1];
$text[$i] = $res[2];
$str = "['images/fla/".$image[$i]."','','','".$text[$i]."'],";
echo $str;
$i++;
}

echo "['images/fla/','','','']";

?>

//<--no trailing comma after very last image element!
],
displaymode: {type:'auto', pause:2500, cycles:0, wraparound:false},
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
descreveal: "always",
togglerid: ""
};

mygallery.imagearray.pop();

new fadeSlideShow(mygallery);