读取javascript中的Cookie
在textboxonchange属性上,我调用了一个javascript函数 我写了这封信读取javascript中的Cookie,javascript,jquery,cookies,Javascript,Jquery,Cookies,在textboxonchange属性上,我调用了一个javascript函数 我写了这封信 function testbox1() { var strline1side1 = document.frmartwork.side1textbox1.value; document.cookie="lineside1="+strline1side1.replace(" "," ")+";path=/;"; } 我想在重新加载页面时分配此“lineside1”cookie值 window.onloa
function testbox1()
{
var strline1side1 = document.frmartwork.side1textbox1.value;
document.cookie="lineside1="+strline1side1.replace(" "," ")+";path=/;";
}
我想在重新加载页面时分配此“lineside1”cookie值
window.onload=function()
{
document.frmartwork.side1textbox1.value = "here i want that cookie "
}
我怎样才能做到这一点呢?如果您使用的是jQuery-使用插件。它使用起来很简单
$.cookies('cookiename') // get value
$.cookies('cookiename', value) // set value
function testbox1()
{
$.cookies('lineside1', $('#side1textbox1').val());
}
$(document).ready(function(){
$('#side1textbox1').val($.cookies('lineside1'));
});
另外,如果您开始使用jQuery,请使用它:)您应该使用jquerycookie
可能重复的$('#side1textbox1').val($.cookies('lineside1'));我使用了这个,但它不是workingdocument.frmartwork.side1textbox1.value=document.cookie['lineside1'];但它让我看到了“未定义”
function testbox1()
{
var strline1side1 = document.frmartwork.side1textbox1.value;
$.cookie('lineside1',strline1side1.replace(" "," "));
}
window.onload=function()
{
document.frmartwork.side1textbox1.value = $.cookie('lineside1')
}