Jump to content

[SOLVED] Banner rotation compatibility issues with FireFox


director87

Recommended Posts

I receive no output when I test the page in FireFox, although it works perfectly in IE. (Please ignore the PHP as it works fine in both... i think... )

 

<ilayer id="l1">
<layer id="l2">
	<div id="l1">
		<div id="l3" style="position:relative">
		</div>
	</div>
</layer>
</ilayer>

<script language="JavaScript">

var bannerArray = new Array();
var myCount=0;
<?php do { ?>
bannerArray[<?php echo $array ?>] = "<A HREF=\"www.fgmetals.com/jose/coloboraciones_afull.php?coloborador=<?php echo $row_Recordset2['pk']; ?>\"><IMG SRC=\"../../img/grande/<?php echo $row_Recordset2['imagen']; ?>\" border=\"0\" width=\"195\" height=\"160\"></A>";
<?php $array++; } while ($row_Recordset2 = mysql_fetch_assoc($Recordset2)); ?>

bannerRotate();

function bannerRotate() {

if(myCount > bannerArray.length-1){myCount=0;}


if (document.all){			
	document.all.l3.innerHTML=bannerArray[myCount];
}

else if (document.layers){	

document.layers.l1.document.layers.l2.document.open();
document.layers.l1.document.layers.l2.document.write(bannerArray[myCount]);
document.layers.l1.document.layers.l2.document.close();
}
setTimeout("bannerRotate()", 10000);
myCount++;
}
</script>

 

Any and all help is appreciated. Thanks.

Link to comment
Share on other sites

So you are using the below code to catch the browser:

if (document.all)
else if (document.layers){

 

I had tried out this:

document.layers

on firefox, it is not a element that recognize by ff. So that's why you can't run this code in FF.

 

I had read your code, it seems that you just need the content of an element will change (rotate) in 10sec.

Why not you just put and simple <div> tag with an id.

 

<div id="content"></div>

 

later on you just put your content using js like this:

document.getElementById("content").innerHTML = bannerArray[myCount];

 

In whole will look like this:

<div id="content"></div>

<script language="JavaScript">

var bannerArray = new Array();
var myCount=0;
<?php do { ?>
bannerArray[<?php echo $array ?>] = "<A HREF=\"www.fgmetals.com/jose/coloboraciones_afull.php?coloborador=<?php echo $row_Recordset2['pk']; ?>\"><IMG SRC=\"../../img/grande/<?php echo $row_Recordset2['imagen']; ?>\" border=\"0\" width=\"195\" height=\"160\"></A>";
<?php $array++; } while ($row_Recordset2 = mysql_fetch_assoc($Recordset2)); ?>

bannerRotate();

function bannerRotate() {

if(myCount > bannerArray.length-1){myCount=0;}


document.getElementById("content").innerHTML = bannerArray[myCount];
setTimeout("bannerRotate()", 10000);
myCount++;
}
</script>

 

This make much more easier.  ;)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.