I have a strange issue when I'm trying to call a method in javascript file. This .js file has 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;
}
On a button click when I use onclick="setTheCookie('cookie_bar_hide', 'yes', 365)"
it gets called, but when I use onclick="setCookie('cookie_bar_hide', 'yes', 365)"
it does not get called.
Any ideas why this could be happening?
There is something else setting setCookie
From the console
> setCookie
function setCookie(name, value)
{
document.cookie = escape($.trim(name)) + '=' + escape(value) + ';path=/';
}
Looking through all of the JavaScript files, setCookie
is located in your base.js
and cookie.js
.
I believe it may have to do with how you are calling your functions on the onClick event. Call multiple methods like this:
onClick="doSomething();doSomethingElse();"
Not with multiple OnClick's.
Let me know if this fixes the problem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.