Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Go Back   Code Forums > Application and Web Development > HTML, XML, Javascript, AJAX
User Name
Password

Reply
 
LinkBack Thread Tools Display Modes
Old 03-09-2005, 10:00 AM   #1 (permalink)
bab1b0y
Registered User
 
Join Date: Mar 2005
Posts: 1
bab1b0y is on a distinguished road
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>
__________________
bab1b0y is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mozilla FireFox sde Code Newbie News 1 02-24-2004 08:50 PM
Javascriptin' like there ain't no tomorrow saline Saline's Brain Teasers 7 03-12-2003 01:17 AM
javascript function help.. Admin HTML, XML, Javascript, AJAX 2 03-09-2003 06:35 PM


All times are GMT -8. The time now is 12:08 AM.


Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle