好的, 所以我使用jquery创建了一个cookie并在其中存储了一个div。 这个div有很多格式化,其他divs,文本等等。使用jQuery存储和检索cookie中的div
var rentContainer = document.createElement('div');
rentContainer.setAttribute("class","module");
var carContainer = document.createElement('div');
carContainer.setAttribute("class","carRentContainer");
rentContainer.appendChild(carContainer);
.... and a lot of other things go in this rentContainer div
现在保存在cookie的
$.cookie('rented_car', rentContainer);
万物看起来不错高达现在。
当页面刷新和正文加载时,现在是时候得到这个div并在页面上显示它(具有相同的格式,结构等)。
所以在我的功能我有
var rented_car_cookie = $.cookie("rented_car");
if(rented_car_cookie){
document.getElementById('rentit').appendChild(rented_car_cookie);
//rentit is already defined and exists on the page. All I need is to add the cookie div content on it.
,但是这给了我一个错误信息
Firebug的日志已经达到极限。 0个条目未显示。首选项
未捕获异常:[Exception ...“无法转换JavaScript参数arg 0 [nsIDOMHTMLDivElement.appendChild]”nsresult:“0x80570009(NS_ERROR_XPC_BAD_CONVERT_JS)”location:“JS frame :: iGo.js :: checkCookies :: line 10 “data:no]
请帮忙。做这个的最好方式是什么?
感谢您的帮助 – kk1957