Reputation: 1
I have a page with a "left" div, that contains a menu, and a "right" div, which holds a content that changes, loaded using javascript as in:
document.getElementById("content").innerHTML='<object type="text/html" data="templates/login.htm"> </object>';
It works okay the first time I click a link on the left menu. Now, this new loaded content has also some inputs that should do the same thing. Only it seems that they can't see the "content" div as having this id, or something else. How do I accomplish this? (fixed menu on left, and on the right we would have changing content - which would have several inputs as well). Thanks.
ADDENDUM - The contents of the js function is just the line pasted above. Probably the flow will clarify? Step 1 - load menu on left and initial content on right. No user intervention Step 2 - click "login" on left menu. Login page (separate html) loaded on right side. All fine. Step 3 - click "cancel" in newly loaded login menu on right side... nothing happens, despite that button having the exact same onclick that the left side menu had (the one used to load the login scren in step 2)
When tracing through parents of this "cancel" button, the trace never "saw" the div. This was the output of "parent hunting" object HTMLParagraphElement (button is in a
) object HTMLTableCellElement object HTMLTableRowElement object HTMLTableSectionElement object HTMLTableElement (so far so good... this should be a table containing the button clicked) object HTMLBodyElement (mmm shouldn't I have a div here?) object HTMLhtmlElement object HTMLDocument null
(now... shouldn't I have a div between body and table elements?) Seems the partial html loaded inside the div cannot see it?
Upvotes: 0
Views: 281
Reputation: 1
Okay...
Seems the loaded content can't intrinsically "see" the parent div or its id by default. The solution was to have:
parent.document.getElementById("content").innerHTML='<object type="text/html" data="templates/login.htm"></object>';
instead of
document.getElementById("content").innerHTML='<object type="text/html" data="templates/login.htm"></object>';
Upvotes: 0
Reputation: 36
If that code-sample is used in your project, the missing > might be the source of your troubles.
document.getElementById("content").innerHTML='<object type="text/html" data="templates/login.htm"></object>';
Upvotes: 1