javascript 파일에서 메소드를 호출하려고 할 때 이상한 문제가 있습니다. 나는 그것이 호출되는 onclick="setTheCookie('cookie_bar_hide', 'yes', 365)"
를 사용할 때javascript 함수가 다른 이름으로 만 호출됩니다.
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;
}
버튼 클릭에,하지만 난 onclick="setCookie('cookie_bar_hide', 'yes', 365)"
를 사용할 때 호출되지 않습니다이 된 .js 파일은 다음 두 가지 방법이있다.
왜 이런 일이 일어날 수 있으리라 생각하십니까?
콘솔에서 console.log (setCookie.toString());가 무엇을 반환합니까? – epascarello
이 'onclick'이있는 전체 요소의 정확한 코드는 무엇입니까? – Teemu
어떤 브라우저를 테스트합니까? –