Is there anything wrong with this code, such as not assigning right or something? All the referenced IDs exist, the console logs it, but only topbar.cw is assigned. I think it might be assigned elsewhere as well, not sure. Also, I’m not even sure what this is. Is it an array, or a class, or a construct or what?
var topbar = {};
if(document.readyState == 'complete'){
topbar.cw=document.getElementById('contentWrapper');
topbar.tb=document.getElementById('topbar');
topbar.hd=document.getElementById('header');
topbar.sm=document.getElementById('storyMenu');
topbar.dd=document.getElementById('dropdown');
topbar.bc=document.getElementById('bodyContent');
topbar.sb=document.getElementById('sidebar');
topbar.mm=document.getElementById('mainMenu');
topbar.da=document.getElementById('displayArea');
console.log("fired when done loading");
}
In the code:
Assigns a new object to
topbarIf the value of
document.readyStateis equivalent to the string ‘complete’, then:Assign the result of the call on the RHS to the
cwproperty oftopbar. If such a property doesn’t exist, it is created.If there is and element with an id of contentWrapper, assign a reference to the
cwproperty. If no element with an id of contentWrapper exists, a value ofnullwill be assigned, since that’s what document.getElementById is specified to return if it can’t find a matching element.Is the above message ever displayed in the console? Have you tried:
If not, try it. Report what you see.