Forum Moderators: open

Message Too Old, No Replies

Mac Explorer Javascript Issue

         

kiwidesign

4:44 am on Aug 22, 2005 (gmt 0)

10+ Year Member



Hi,
I am trying to rotate an image (every so many seconds) on a page. I have a php page that calls another php page that has the javascript in it.
It works in Mozilla and explorer on PC, Opera on Mac but
does NOT work in Explorer (5.2) on Mac.

Does anyone know a) Why it doesn't work and b) How I can make it work.

many thanks

Here is the php page with the Javascript code:

<script language="javascript">
imgAr = new Array();
<?php

$file = "./HIR/images.txt";

$lines = file($file);
$count = count($lines);
//echo("Toal Images to rotate".$count."<br>");

$i=0;
$k=0;

foreach ($lines as $line_num => $line)
{
if($k==0)
{
$k=$k+1;
$firstPos = strpos($line,'"');
$secPos = strpos($line,'"',($firstPos+1));
$width = substr($line,$firstPos+1,($secPos-$firstPos)-1);

$firstPos1 = strpos($line,'"',($secPos+1));
$secPos1 = strpos($line,'"',($firstPos1+1));
$height = substr($line,$firstPos1+1,($secPos1-$firstPos1)-1);

$firstPos2 = strpos($line,'"',($secPos1+1));
$secPos2 = strpos($line,'"',($firstPos2+1));
$speed = substr($line,$firstPos2+1,($secPos2-$firstPos2)-1);
}
else
{
//echo $line;
$firstPos = strpos($line,'"');
$secPos = strpos($line,'"',($firstPos+1));
//echo "=======================$firPos-$secPos<br>";
$img[$i] = substr($line,$firstPos+1,($secPos-$firstPos)-1);
$imh = $img[$i];
print "imgAr.push(\"$imh\" );";
//echo $img[$i]."<br>";
$i=$i+1;
}
}
?>
</script>

<script language="javascript">
var k = 0;
var wid12 = <?php echo($width);?>;
var hig12 = <?php echo($height);?>;

if (document.images)
{
var rImg = new Array();
for (var i=0; i<imgAr.length; i++)
{
rImg[i] = new Image(wid12,hig12);
rImg[i].src = imgAr[i];
}
}

function rotater()
{
//var ssd = imgAr[k];
//document["test"].src = ssd;
document["test"].src = rImg[k].src;

if( k < (imgAr.length-1))
{
k= k+1;
}
else
{
k = 0;
}

rTimer = setTimeout('rotater()', <?php echo($speed);?> );

}
</script>

<table align=center cellpading=0 cellspacing=0 border=0>
<tr><td>
<img width="<?php echo($width);?>" height="<?php echo($height);?>" name=test src="<?php echo($img[0]);?>">
</td></tr><tr align=right><td>
<a href="http://www.getrheel.co.nz" target="_blank"><img src="/images/rheelweblogo.gif" border="0"></a>
</td></tr></table>

<script language="javascript">
rotater();
</script>

dcrombie

12:13 pm on Aug 22, 2005 (gmt 0)



There's no point posting your PHP code as the browser doesn't see it. If you post your _actual_ JavaScript and HTML you're more likely to get a response on this (JavaScript) forum ;)

And which part of the script "doesn't work"?

Don_Hoagie

12:43 pm on Aug 22, 2005 (gmt 0)

10+ Year Member



Sorry in advance for replying to this thread without properly answering your questions, but...

IE:Mac is possibly the worst browser out there on the market, which is why it's been killed off by MS. It's likely not an issue with your code, but rather a quirk of the browser. If I were you, I wouldn't worry about building for this browser... anyone with a Mac who has the nerve to run IE:Mac instead of Safari or FF needs to learn a lesson anyway. I'd include a notation on the site that tells IE:Mac users to switch to a different browser, since they already have a perfectly good one built into their Macs.