我完全卡住了,试图从检索函数中获得最好的evercookie值,并将其放入我可以使用的JS或PHP函数中。
下面的代码可以触发best_candidate的警报,但是我不知道如何从函数中返回这个值(我猜是嵌套函数让我犯错),所以我可以在ec.get()函数之外使用这个值。
任何帮助都将不胜感激。谢谢!
function getCookie(best_candidate, all_candidates)
{
alert("The retrieved cookie is: " + best_candidate + "\n" +
"You can see what each storage mechanism returned " +
"by looping through the all_candidates object.");
for (var item in all_candidates)
{
document.write("Storage mechanism " + item +
" returned: " + all_candidates[item] + "<br>");
}
}
ec.get("id", getCookie);发布于 2011-08-04 08:39:42
这个带多个参数的回调函数是针对更具体的需求而设计的。
你所需要的是:
var cookie;
ec.get("id", function(value) { cookie = value; }); https://stackoverflow.com/questions/6933097
复制相似问题