I'm having a strange problem with one of my Javascript functions that only takes place in Opera. All other browsers (IE, FF, Chrome, Safari) work perfectly fine with it. I'm basically hiding a couple of div elements when all cookies with the string "compare" have been deleted (cookies are created in another function). Here's the code:
function removeCookie(item)
{
var getdiv1 = document.getElementById("div1");
var getdiv2 = document.getElementById("div2");
In Opera, the cookies get deleted but for some odd reason the last cookie doesn't get deleted till after the function is done running so the div elements stay visible. Very Strange...Any help with this matter will be greatly appreciated. Thank you.
Thank you for your response. Sorry I tried to condense the entire javascript function to make it simpler to follow but it looks like I left out some key information
1) It refers to the cookie name. Each cookie starts with the following:
compare[id]=id
The id within the brackets is replaced with the product id of the product we want to compare.
2) Yes, the item parameter is specified as "CookieName=CookieValue" with the following code:
var item = "compare" + id + "=id";
document.cookie = item + "; path=/";
id is a parameter passed to the function.
3) It should only pick up a cookie name so once all cookies with the string like "compare" are deleted it should hide the div. It works in all browsers except Opera.
Thanks for your help. Let me know if you want to see the entire JS function.
This is where the problem becomes even stranger. Once the last cookie is removed, the alert shows the following:
PHPSESSID=[random characters]
So there are no cookies and the only thing remaining is the PhP session. Here's the strange part: When I added that line of code for the alert message, the function started working properly, as in the function hid the div elements after all the cookies were removed! Once I removed the alert code, it stopped working again. Weird right?
Bookmarks