I have a parent page that has 2 iframes on it. I set a cookie on the parent page. I need to access that cookie in each of the iframes. The iframes are on the same domain as the parent. The iframes have id’s of “searchresults” and “games”.
Based on what the cookie is set to (“thumbnail” or “textlist” view) the content <div>’s will be displayed or turned off.
//If the listview equals thumbnail then display the thumbnail view <div>
var whatisit = top.getCookie(“listview”);
alert(“is this my cookie = “+getCookie(“listview”));
alert(“is this my cookie2 = “+whatisit);
if (top.document.getCookie(“listview”) == “thumbnail”) {
[INDENT]//top.frames[‘searchresults’].document.getElementById(‘videolist’).style.display=’none’;
top.frames[‘searchresults’].document.getElementById(‘videolist2′).style.display=’block’;[/INDENT]
}
I believe my problem is that I’m not referencing the document object correctly to refer to the cookie. When writing an alert of the cookie from the iframe I get “undefined” as the message instead of the cookie value.
Thanks in advance.