Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Firefox / Internet Explorer

Status
Not open for further replies.

Jonnn

Programmer
Nov 17, 2004
135
GB
Why will a javascript application work with I.E but not with Firefox?

I have a problem with saving cookies via a website using Firefox, but with I.E, it is not a problem...

I have my cookies enabled on Firefox yet they still fail to save...

Any advice appreciated :-

- Jon

JavaScript Beginner at work :)
 
Post the code :)

----------
Memoria mihi benigna erit qui eam perscribam
 

Why will a javascript application work with I.E but not with Firefox?

The main reasons are when the code is badly written, using IE-specific code, or IE coding shortcuts.

As stormbind says, post your code, otherwise it'll be a long hard slog to find a solution.

Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
No problem lads ... here is my js

Code:
// ------------------------------------------------------------------------------- FUNCTIONS START

playerName=""; // creates a blank variable which will hold the players name

function loadCookie() {

cookie = document.cookie; // puts the value of the cookie into the variable "cookie"

allCookies = cookie.split(";"); // splits the cookie up into an array called "allCookieS"
	
	for(x=0; x < allCookies.length; x++) { // look throught each slot in the "allCookies" array
	if(foundIt == "yes")	{ // if the cookie is found, break the loop
	break; // this statement breaks the loop
	}
		var cookieValue = allCookies[x]; // stores each slots info in the variable "cookieValue" every time through the loop
		
		for(y=0; y < profileNamesArr.length; y++) { // loops throught the selections array

		if(foundIt == "yes") { // if the cookie is found, break the loop
		break; // this statement breaks the loop
		}	 
			if(cookieValue == profileNamesArr[y]) { // if the cookie value is equal to a selection
			
			if(window.location == "[URL unfurl="true"]http://www.freewebs.com/foxandhounds/team_stats.html")[/URL] {
			if(cookieValue != "Visitor") {
			document.getElementById(cookieValue).style.backgroundColor="#eaffea";
			}
			}
			
			if( (window.location == "[URL unfurl="true"]http://www.freewebs.com/foxandhounds/")[/URL] || (window.location == "[URL unfurl="true"]http://www.freewebs.com/foxandhounds/index.html")[/URL] ) {
			playerName = "<strong>" + cookieValue + "</strong>"; // change the onscreen name
			}
			
			var foundIt = "yes" // alert the loop that the cookie has been found
			break; // break the loop by using this statement
			}
		}
	
	}
	
}

function confirmProfile() {

selectedNumber = document.getElementById("choosePlayer").selectedIndex

selectedPlayer = document.form1.choosePlayer.options[selectedNumber].name

expireTime = new Date(); // create a new blank date

oneYear = 1000*60*60*24*7*52 // 1000 milliseconds in a second. 1000 * 60 = 1min, *60 = 1hour, *24 = 1day * 53 = 1 year
expireTime.setTime(expireTime.getTime() + oneYear); // set the time of blank date to the current date + 1day



// create the cookie using the following: - 1)name of cookie, 2)contents of cookie, 3)expiry date of cookie

document.cookie = selectedPlayer + "; expires=" + expireTime.toGMTString(); 

alert("Thank you " + selectedPlayer + ", you will now be redirected to the main page");

window.location="[URL unfurl="true"]http://www.freewebs.com/foxandhounds/index.html";[/URL]
}


function not_yet() {
alert("Not yet available");
}

function draw_fixture(date, home, away, result) {

if(fixture_date[12] == date) {

document.write("<tr onmouseover=\"this.bgColor='#eaffea'\" onmouseout=\"this.bgColor='white'\">");

document.write("<td class='font' width='15%' align='left'>");
document.write("<span style='color:red;'>" + date + "</span>");
document.write("</td>");

document.write("<td class='font' width='15%' align='right'>");
document.write("<span style='color:red;'>" + home + "</span>");
document.write("</td>");

document.write("<td class='font' width='10%' align='center'>");
document.write("<span style='color:red;'>" + "VZ" + "</span>");
document.write("</td>");

document.write("<td class='font' width='15%' align='left'>");
document.write("<span style='color:red;'>" + away + "</span>");
document.write("</td>");

document.write("<td class='font' width='10%' align='left'>");
document.write("<span style='color:red;'>" + result + "</span>");
document.write("</td>");

document.write("</tr>");

}

else {

document.write("<tr onmouseover=\"this.bgColor='#eaffea'\" onmouseout=\"this.bgColor='white'\">");

document.write("<td class='font' width='15%' align='left'>");
document.write(date);
document.write("</td>");

document.write("<td class='font' width='15%' align='right'>");
document.write(home);
document.write("</td>");

document.write("<td class='font' width='10%' align='center'>");
document.write("VZ");
document.write("</td>");

document.write("<td class='font' width='15%' align='left'>");
document.write(away);
document.write("</td>");

document.write("<td class='font' width='10%' align='left'>");
document.write(result);
document.write("</td>");

document.write("</tr>");

}
}

function blank_row() {
            		
document.write("<tr align=\"center\">")
	
document.write("<td class=\"font\" width=\"15%\"> &nbsp </td>")
document.write("<td class=\"font\" width=\"15%\"> &nbsp </td>")
document.write("<td class=\"font\" width=\"10%\"> &nbsp </td>")
document.write("<td class=\"font\" width=\"15%\"> &nbsp </td>")
document.write("<td class=\"font\" width=\"10%\"> &nbsp </td>")     		
document.write("</tr>")

}


function display_date() {
date_now = new Date();
month = date_now.getMonth()
day = date_now.getDate();
my_date = find_month[month] + " " + find_day[day]
document.write("<span style='color: red;'>" + my_date + "</span>")
}



// ------------------------------------------------------------------------------- FUNCTIONS END



// ------------------------------------------------------------------------------- ARRAYS START

var profileNamesArr = new Array();
profileNamesArr[0] = "Visitor";
profileNamesArr[1] = "Dave";
profileNamesArr[2] = "Dave (owner)";
profileNamesArr[3] = "Jonathan";
profileNamesArr[4] = "John";
profileNamesArr[5] = "Little John";
profileNamesArr[6] = "Kev";
profileNamesArr[7] = "Kev (barman)";
profileNamesArr[8] = "Mick";
profileNamesArr[9] = "Paul";
profileNamesArr[10] = "Sean";

var fixture_date = new Array();
fixture_date[0]   = "Feb 10th";
fixture_date[1]   = "Feb 17th";
fixture_date[2]   = "Feb 24th";
fixture_date[3]   = "March 3rd";
fixture_date[4]   = "March 10th";
fixture_date[5]   = "March 17th";
fixture_date[6]   = "March 24th";
fixture_date[7]   = "March 31st";
fixture_date[8]   = "April 7th";
fixture_date[9]   = "April 14th";
fixture_date[10]  = "April 21st";
fixture_date[11]  = "April 28th";
fixture_date[12]  = "May 5th";
fixture_date[13]  = "May 12th";
fixture_date[14]  = "May 19th";
fixture_date[15]  = "May 26th";
fixture_date[16]  = "June 2nd";
fixture_date[17]  = "June 9th";
fixture_date[18]  = "June 16th";
fixture_date[19]  = "June 23rd";
fixture_date[20]  = "June 30th";
fixture_date[21]  = "July 7th";

var find_month = new Array("Jan", "Feb", "March", "April", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec");

{ 
var find_day   = new Array("blankspace", "1st", "2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th",
"12th", "13th", "14th", "15th", "16th", "17th", "18th", "19th", "20th", "21st", "22nd", "23rd", "24th", "25th", "26th",
"27th", "28th", "29th", "30th", "31st");
}



// ------------------------------------------------------------------------------- ARRAYS END



// NEXT PAGE ***********************************************************************************************




// ------------------------------------------------------------------------------- FUNCTIONS START


function draw_stats(name, games_played, wins, loss, win_streak, win_percentage, id_name) {

document.write("<tr align='center' id='" + id_name + "' onmouseover=\"this.bgColor='#eaffea'\" onmouseout=\"this.bgColor='white'\">");

document.write("<td class='font'>");
document.write(name);
document.write("</td>");

document.write("<td class='font'>");
document.write(games_played);
document.write("</td>");

document.write("<td class='font'>");
document.write(wins);
document.write("</td>");

document.write("<td class='font'>");
document.write(loss);
document.write("</td>");

document.write("<td class='font'>");
document.write(win_streak);
document.write("</td>");

document.write("<td class='font'>");
var value = Math.round(win_percentage * 100) / 100
document.write(value + "%");
document.write("</td>");

document.write("</tr>");
}

function change_border(color) {
document.getElementById("table1").borderColor=color;
}


function hall_of_fame(array,array1,sorter) {
var y=0;

array.sort(sorter); 			                // sorts array into order
var top_score = array[0];              			// gets value of most wins

var more_than_one = new Array();			// creates array to store players that have the same amount of wins..

for(var x=0; x < array1.length; x++) {			// loops through wins array
if(top_score == array1[x]) { 				// if highest win value is equal to one of the players amount of wins							
more_than_one[y++] = nameArr[x];			// amount goes up if more than one player has the same amount of wins					        	 
}
}

for(var z=0; z < more_than_one.length; z++) {
if(z == more_than_one.length-1) {
document.write(more_than_one[z]);
break;
}

else{
document.write(more_than_one[z] + " - ");
}
}
}


function sort_array_ascending(value1,value2) { 
if(value1 > value2) {
return 1;
}

if(value1 == value2) {
return 0;
}

if(value1 < value2) {
return -1;
}
}


function sort_array_descending(value1,value2) {
if(value1 > value2) {
return -1;
}

if(value1 == value2) {
return 0;
}

if(value1 < value2) {
return 1;
}
}


// ------------------------------------------------------------------------------- FUNCTIONS END





// ------------------------------------------------------------------------------- ARRAYS START


var nameArr = new Array();   // List of players in the team
nameArr[0]  = "Dave"; 
nameArr[1]  = "Dave (owner)"; 
nameArr[2]  = "John";
nameArr[3]  = "Jonathan";
nameArr[4]  = "Little John";
nameArr[5]  = "Kev";
nameArr[6]  = "Kev (barman)";
nameArr[7]  = "Mick";
nameArr[8]  = "Paul";
nameArr[9]  = "Sean";


var gamesplayedArr = new Array();   // amount of games played
gamesplayedArr[0]  =  1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0;  // Dave
gamesplayedArr[1]  =  0 + 0 + 0 + 1 + 0 + 1 + 0 + 1 + 0 + 0 + 1 + 1;  // Dave (owner)
gamesplayedArr[2]  =  1 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1;  // John
gamesplayedArr[3]  =  0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1;  // Jonathan
gamesplayedArr[4]  =  1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 1;  // Little John
gamesplayedArr[5]  =  1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1;  // Kev
gamesplayedArr[6]  =  1 + 1 + 0 + 1 + 1 + 0 + 1 + 1 + 0 + 1 + 0 + 0;  // Kev (barman)
gamesplayedArr[7]  =  0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 0 + 0 + 0;  // Mick
gamesplayedArr[8]  =  1 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1;  // Paul
gamesplayedArr[9]  =  1 + 1 + 1 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 1 + 1;  // Sean




var winsArr = new Array();   // amount of games players have won
winsArr[0]  =  1 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 0 + 1 + 0 + 0;    // Dave
winsArr[1]  =  0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0;    // Dave (owner)
winsArr[2]  =  1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0;    // John
winsArr[3]  =  0 + 1 + 0 + 1 + 0 + 1 + 0 + 1 + 0 + 0 + 1 + 0;    // Jonathan
winsArr[4]  =  0 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 1 + 1;    // Little John
winsArr[5]  =  1 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + 0;    // Kev
winsArr[6]  =  0 + 1 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 0;    // Kev (barman)
winsArr[7]  =  0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0;    // Mick
winsArr[8]  =  1 + 0 + 0 + 1 + 1 + 1 + 1 + 1 + 1 + 0 + 0 + 0;    // Paul
winsArr[9]  =  0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0;    // Sean



var lossArr = new Array();  // amount of games players have lost
lossArr[0]  =  0 + 1 + 0 + 0 + 1 + 0 + 1 + 0 + 1 + 0 + 0 + 0;   // Dave 
lossArr[1]  =  0 + 0 + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + 1 + 1;   // Dave (owner)
lossArr[2]  =  0 + 0 + 1 + 1 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1;   // John
lossArr[3]  =  0 + 0 + 1 + 0 + 1 + 0 + 1 + 0 + 1 + 1 + 0 + 1;   // Jonathan
lossArr[4]  =  1 + 0 + 1 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + 0 + 0;   // Little John
lossArr[5]  =  0 + 0 + 0 + 1 + 0 + 1 + 1 + 1 + 0 + 1 + 1 + 1;   // Kev
lossArr[6]  =  1 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 0 + 1 + 0 + 0;   // Kev (barman)
lossArr[7]  =  0 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 0 + 0 + 0 + 0;   // Mick
lossArr[8]  =  0 + 0 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1;   // Paul
lossArr[9]  =  1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1;   // Sean



var winStreakArr = new Array();  // players winning streaks
winStreakArr[0]  = "+1";   // Dave
winStreakArr[1]  = "+0";   // Dave (owner)
winStreakArr[2]  = "+0";   // John
winStreakArr[3]  = "+0";   // Jonathan
winStreakArr[4]  = "+2";   // Little John
winStreakArr[5]  = "+0";   // Kev
winStreakArr[6]  = "+0";   // Kev (barman)
winStreakArr[7]  = "+0";   // Mick
winStreakArr[8]  = "+0";   // Paul
winStreakArr[9]  = "+0";   // Sean



var winPercentageArr = new Array();  // players winning streaks
winPercentageArr[0]  = Math.round(winsArr[0] / gamesplayedArr[0] * 100); 
winPercentageArr[1]  = Math.round(winsArr[1] / gamesplayedArr[1] * 100); 
winPercentageArr[2]  = Math.round(winsArr[2] / gamesplayedArr[2] * 100); 
winPercentageArr[3]  = Math.round(winsArr[3] / gamesplayedArr[3] * 100);   
winPercentageArr[4]  = Math.round(winsArr[4] / gamesplayedArr[4] * 100);   
winPercentageArr[5]  = Math.round(winsArr[5] / gamesplayedArr[5] * 100);   
winPercentageArr[6]  = Math.round(winsArr[6] / gamesplayedArr[6] * 100);   
winPercentageArr[7]  = Math.round(winsArr[7] / gamesplayedArr[7] * 100);   
winPercentageArr[8]  = Math.round(winsArr[8] / gamesplayedArr[8] * 100);   
winPercentageArr[9]  = Math.round(winsArr[9] / gamesplayedArr[9] * 100);  

var mostWinsArr = new Array();
mostWinsArr[0]  =  winsArr[0];
mostWinsArr[1]  =  winsArr[1];     
mostWinsArr[2]  =  winsArr[2];   
mostWinsArr[3]  =  winsArr[3];   
mostWinsArr[4]  =  winsArr[4];   
mostWinsArr[5]  =  winsArr[5];   
mostWinsArr[6]  =  winsArr[6];   
mostWinsArr[7]  =  winsArr[7];   
mostWinsArr[8]  =  winsArr[8];
mostWinsArr[9]  =  winsArr[9];  

var mostLossArr = new Array(); 
mostLossArr[0]  =  lossArr[0]; 
mostLossArr[1]  =  lossArr[1];   
mostLossArr[2]  =  lossArr[2];  
mostLossArr[3]  =  lossArr[3];   
mostLossArr[4]  =  lossArr[4];   
mostLossArr[5]  =  lossArr[5];   
mostLossArr[6]  =  lossArr[6];   
mostLossArr[7]  =  lossArr[7];   
mostLossArr[8]  =  lossArr[8]; 
mostLossArr[9]  =  lossArr[9];  

var bestStreakArr = new Array();  
bestStreakArr[0]  =  winStreakArr[0]; 
bestStreakArr[1]  =  winStreakArr[1];  
bestStreakArr[2]  =  winStreakArr[2]; 
bestStreakArr[3]  =  winStreakArr[3];
bestStreakArr[4]  =  winStreakArr[4];
bestStreakArr[5]  =  winStreakArr[5];
bestStreakArr[6]  =  winStreakArr[6];
bestStreakArr[7]  =  winStreakArr[7];
bestStreakArr[8]  =  winStreakArr[8];
bestStreakArr[9]  =  winStreakArr[9];

var bestWinPercentageArr = new Array();   
bestWinPercentageArr[0] = winPercentageArr[0];
bestWinPercentageArr[1] = winPercentageArr[1];
bestWinPercentageArr[2] = winPercentageArr[2];
bestWinPercentageArr[3] = winPercentageArr[3];
bestWinPercentageArr[4] = winPercentageArr[4];
bestWinPercentageArr[5] = winPercentageArr[5];
bestWinPercentageArr[6] = winPercentageArr[6];
bestWinPercentageArr[7] = winPercentageArr[7];
bestWinPercentageArr[8] = winPercentageArr[8];
bestWinPercentageArr[9] = winPercentageArr[9];

// ------------------------------------------------------------------------------- ARRAYS END

// NEXT PAGE ***********************************************************************************************



// FUNCTIONS START

function open_news(name,number) {

var news_text = new Array();
news_text[0] = "Finally I have finished the design of the website adding various links which will help with the running of the team. I hope you all like it! <br/><br/> - Jon.";
news_text[1] = "I think it would be a good idea to choose a day in the week most suitable for everyone where we can all practice before Thursday's. As i say, just an idea I think we should concentrate on. <br/><br/> - Jon";
news_text[2] = "Singles and Doubles Tournaments are coming up very soon with the entry fee being £1 per man. If you would like to enter, see Paul (Captain) A.S.A.P <br/><br/> - Jon";
news_text[3] = "";
news_text[4] = "";
news_text[5] = "";
news_text[6] = "";

var window1 = window.open("","window1", "width=200,height=200,left=400,top=375")
window1.document.write("<div style='background-color:f6fff5'>")
window1.document.write("<span style='font-family: verdana; font-size: 10; color: green;'>")
window1.document.write("<span style='color:red'>" + name + "</span>" + "<br/><br/>")
window1.document.write(news_text[number])
window1.document.write("</span>")
window1.document.write("<br/><br/>")
window1.document.write("<input type='button' value='Close Window' onclick='window.close()'>")
window1.document.write("</div>")

window1.focus()
}

// FUNCTIONS END

Type away :)

- Jon

JavaScript Beginner at work :)
 
Another thing is when using Firefox on this website ...


on the links


sometimes when i visit the links, the fixtures and team stats tables spread across the whole width of the main table. ruining the background, but then sometimes they work perfect...

any explanation for this type of behaviour?

- Jon

JavaScript Beginner at work :)
 
try checking my Validation button ...

i have over 200 errors, am i linking to a undefined DTD???

JavaScript Beginner at work :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top