I've encountered an unusual problem when attempting to invoke a method in a JavaScript file. This particular .js file contains the following two methods:
function setCookie(c_name, value, exdays)
{
//set the expiry date as now + the specified number of days
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
//add the expiry date string to the cookie value
var c_value = escape(value) + ((exdays==null) ? "" : ";
expires="+exdate.toUTCString()+"; path=/");
//set the cookie
document.cookie = c_name + "=" + c_value;
}
function setTheCookie(c_name, value, exdays)
{
//set the expiry date as now + the specified number of days
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
//add the expiry date string to the cookie value
var c_value = escape(value) + ((exdays==null) ? "" : ";
expires="+exdate.toUTCString()+"; path=/");
//set the cookie
document.cookie = c_name + "=" + c_value;
}
When I click a button and use
onclick="setTheCookie('cookie_bar_hide', 'yes', 365)"
, it works fine. However, when I try onclick="setCookie('cookie_bar_hide', 'yes', 365)"
, the method is not executed.
Does anyone have any insights into why this might be occurring?