0

The code works perfect in IE but I can't get it to work in Firefox. Is there a work around for firefox?
Your time and help are greatly appreciated.
dinkado

<script language="JavaScript">




//put your text here
var theText = "This is test text";

function nextSize(i,incMethod,textLength)
{
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
}

function sizeCycle(text,method,dis)
{
	output = "";
	for (i = 0; i < text.length; i++)
	{
		size = parseInt(nextSize(i +dis,method,text.length));
		output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
	}
	theDiv.innerHTML = output;
}

function doWave(n) 
{   
	sizeCycle(theText,1,n);
	if (n > theText.length) {n=0}
	setTimeout("doWave(" + (n+1) + ")", 50);
}
</script>
<div ID="theDiv" align="center">

</div>


<body onload="doWave(0)">
3
Contributors
4
Replies
8
Views
7 Years
Discussion Span
Last Post by fxm
0

Works fine here (once the elements are assembled into a page in the proper order).

0

Properly formed HTML is your friend in FF IE won't necessarily care.
Try:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
<head>
	<script language="JavaScript">
 //put your text here
var theText = "This is test text";
 
function nextSize(i,incMethod,textLength)
{
if (incMethod == 1) return (72*Math.abs( Math.sin(i/(textLength/3.14))) );
if (incMethod == 2) return (255*Math.abs( Math.cos(i/(textLength/3.14))));
}
 
function sizeCycle(text,method,dis)
{
	var theDiv = document.getElementById("theDiv");
	output = "";
	for (i = 0; i < text.length; i++)
	{
		size = parseInt(nextSize(i +dis,method,text.length));
		output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
	}
	theDiv.innerHTML = output;
}
 
function doWave(n) 
{   
	sizeCycle(theText,1,n);
	if (n > theText.length) {n=0}
	setTimeout("doWave(" + (n+1) + ")", 50);
}
</script>
</head>
 
 
<body onload="doWave(0)">
<div ID="theDiv" align="center">
 
</div>
</body>
</html>

Also note the code I have highlighted. You didn't have a variable assigned to the Div element so it wasn't working for me in FF. Could have been a typo from when you posted but it would cause issues.

0

Thanks so much scrappedcola!! It works like a charm now.
dinkado

0

FWIW: with this DTD

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

Firefox will be in 'quirks mode', so this function exactly as originally posted

function sizeCycle(text,method,dis)
{
	output = "";
	for (i = 0; i < text.length; i++)
	{
		size = parseInt(nextSize(i +dis,method,text.length));
		output += "<font style='font-size: "+ size +"pt'>" +text.substring(i,i+1)+ "</font>";
	}
	theDiv.innerHTML = output;
}

works as intended.

Edited by fxm: n/a

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.