close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Javascript cookies only work in FireFox

Thread began 6/13/2010 10:20 am by biesheuvel378713 | Last modified 6/12/2015 11:08 am by Justin Hood | 4100 views | 4 replies |

biesheuvel378713

Javascript cookies only work in FireFox

I've written this code to change some font formats in one of my websites I've made with joomla (and designed with css sculptor.

For some reason it only works in Firefox and I can't get my hand on where the error is. Does somebody know what's going wrong here?

function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}



function getFontSize(){
var size = readCookie("fontsize");
if (size== null) return "normal"; else return size;
}


(function($) {

function setFontSize (size)
{



if (size == "small")
{
$("#contentWrapper").css("font-size", "10px");
$("#contentWrapper h1").css("font-size","14px");
$("#contentWrapper h2").css("font-size", "12px");
}

if (size == "big")
{
$("#contentWrapper").css("font-size","14px");
$("#contentWrapper h2").css("font-size","16px");
$("#contentWrapper h1").css("font-size","18px");
}

if (size =="normal")
{
$("#contentWrapper").css("font-size","12px");
$("#contentWrapper h2").css("font-size","14px");
$("#contentWrapper h1").css("font-size","16px");
}


document.cookie="fontsize=" + size + ";max-age=" + (60*60*24*365) ;
}




$(document).ready(function(){

var size = getFontSize();
setFontSize (size);



$('a#smallFont').click(function(e){
e.preventDefault();
setFontSize('small');
return false;
});

$('a#normalFont').click(function(e){
e.preventDefault();
setFontSize('normal');
return false;
});

$('a#bigFont').click(function(e){
e.preventDefault();
setFontSize('big');
return false;
});




}); // document ready


})(jQuery)

Sign in to reply to this post

CraigRBeta Tester

i tried the url in FF3 and IE8 (and chrome) and it works on my machine.

Sign in to reply to this post

biesheuvel378713

Well, as i found out, there where two cookies stored with the same name in the cash, for some reason it didn't erase them. I have cleaned the cash with a third party program and then it actually worked as it should be. Neither IE or Chrome had cleaned the cookies as supposed to do. Thank you very much for your reply it got me in the right direction.

Sign in to reply to this post

miledhector411461

Hi Mate

I have worked on it. It works in IE8 or higher versions.Please change settings of IE.

Sign in to reply to this post

Jackie Bolinsky

Hi,

Generally speaking, when given a cookie that has no expiration period, modern browsers will consider this cookie to be a 'session cookie', they will remove the cookie at the end of the browsing session (generally when the browser instance closes).

IE, Opera, Safari and Chrome all support this behavior.

However firefox (3.0.9 latest proper release) appears not to follow this rule, from what I can tell it doesn't expire the cookies when the browser is closed, or when the user logs off or restarts the OS...

Thanks,
Jackie

________________
Javascript Countdown Timer

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...