Javascript 如何获取主体加载事件的cookie?
我有一个这样的对话框Javascript 如何获取主体加载事件的cookie?,javascript,jquery,cookies,Javascript,Jquery,Cookies,我有一个这样的对话框 <div id="savedialog" class="pop1"> <div id="center" style="margin:30px;"> <h1 style="font-size:20px;color:#000;margin-bottom:0;">Ready to Save Your Quote?</h1> <p style="font-size:12px;
<div id="savedialog" class="pop1">
<div id="center" style="margin:30px;">
<h1 style="font-size:20px;color:#000;margin-bottom:0;">Ready to Save Your Quote?</h1>
<p style="font-size:12px;margin-bottom:0;">
<span style="font-weight:bold;">Email</span>
<input style="margin-bottom:15px; margin-left:90px;" type="text" id="email" name="email" placeholder="" />
<p style="font-size:12px;margin-bottom:0;">
<span style="font-weight:bold;">Confirm Email</span>
<input style="margin-bottom:15px; margin-left:40px;" type="text" id="confirm_email" name="confirm_email" placeholder="" />
</p>
<hr style="border-bottom:1px dotted #ccc;">
</p>
<p>
<input type="hidden" name="action" value="popshow"/>
<input class="btn btn-primary btn-large" type="button" id="directory" value="Save quote" >
<a href="#" id="cnl24">Cancel</a>
</p>
</div>
</div>
<body onload="checkCookie();">
我调用了一个函数来检查cookie,就像这样
<div id="savedialog" class="pop1">
<div id="center" style="margin:30px;">
<h1 style="font-size:20px;color:#000;margin-bottom:0;">Ready to Save Your Quote?</h1>
<p style="font-size:12px;margin-bottom:0;">
<span style="font-weight:bold;">Email</span>
<input style="margin-bottom:15px; margin-left:90px;" type="text" id="email" name="email" placeholder="" />
<p style="font-size:12px;margin-bottom:0;">
<span style="font-weight:bold;">Confirm Email</span>
<input style="margin-bottom:15px; margin-left:40px;" type="text" id="confirm_email" name="confirm_email" placeholder="" />
</p>
<hr style="border-bottom:1px dotted #ccc;">
</p>
<p>
<input type="hidden" name="action" value="popshow"/>
<input class="btn btn-primary btn-large" type="button" id="directory" value="Save quote" >
<a href="#" id="cnl24">Cancel</a>
</p>
</div>
</div>
<body onload="checkCookie();">
但是我没有得到任何cookie,所以请你告诉我哪里错了。如果你没有定义getCookie函数,请使用这个函数
function getCookie(cname){
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++)
{
var c = ca[i].trim();
if (c.indexOf(name)==0) return c.substring(name.length,c.length);
}
return "";
}
函数getCookie(cname){
变量名称=cname+“=”;
var ca=document.cookie.split(“;”);
for(var i=0;i是否定义了getCookie函数?是的,类似于此函数getCookie(emailID){var name=emailID+“=”;var ca=document.cookie.split(“;”);for(var i=0;i请查看编辑过的答案。好的如果我想在代码中设置时间间隔,我该怎么做