|
Javascript var behaving differently in Mozilla & Firefox than in IE
Can anyone help me firgure out why the following javascript code produces different results dependent on which browser it is view in. Specifically, the var i, on pageload, begins at different values. E.g, IE i begins at 0, NS i begins at 16, and Firefox, i begins at 13:
<script language="javascript" type="text/javascript">
<!--
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
function rnd() {
rnd.seed = (rnd.seed*9301+49297) % 233280;
return rnd.seed/(233280.0);
};
function rand(number) {
return Math.ceil(rnd()*number);
};
var i = 0;
type_string = new Array();
type_string[1] = " How do I become a millionaire?";
type_string[2] = " What exactly is an annuity?";
type_string[3] = " How do I prepare for retirement?";
type_string[4] = " Are there any employment opportunities at ABC?";
type_string[5] = " How do I contact an agent?";
type_string[6] = " How do I view my account?";
type_string[7] = " How do I become an agent?";
type_string[8] = " Which investment strategy is right for me?";
type_string[9] = " How do I manage my taxes?";
type_string[10] = " How do I manage my wealth?";
type_string[11] = " What do I do when someone dies?";
type_string[12] = " How do I buy a ABC insurance policy?";
type_string[13] = " Why is ABC remaining a mutual company?";
type_string[14] = " Which U.S. Presidents placed their trust in New York Life?";
type_string[15] = " Where can I find calculators and worksheets?";
x = rand(15);
function clear() {
// reset textarea
document.searchform3.querystring.value = "";
}
function type() {
// write out one character at a time
document.searchform3.querystring.value += type_string[x].charAt(i);
i++;
// if not at end of string, pause with time delay
if (i <= type_string[x].length) {
var timeID = setTimeout("type()",70);
}
}
//-->
</script>
</head>
<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onLoad="clear(); type();">
<p>Any html goes here.</p>
</body>
</html>
__________________
|