Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing innerHTML in window.opener - Please help!

Status
Not open for further replies.

southbeach

Programmer
Jan 22, 2008
879
0
0
US
I have Page(1) which opens Page(2). Page(2), upon closing by clicking a button, should change the innerHTML of a <div> tab in Page(1).

Here is the code I am using:
Code:
onClick="javascript: window.opener.document.getElementById('showcharges').innerHTML=document.getElementById('chargeslist').innerHTML; window.close();"

I have a tag in Page(1):
Code:
<div id="showcharges"></div>

and a tag in Page(2):
Code:
<div id="chargeslist"></div>

At the time that I click on the button with the above onClick code, I have and show content within the chargeslist tab.

What am I doing wrong?

One thing I suspect as the problem is that Page(2) is really the third window opened from main page. In other words, I have a data grid that opens Page(1), 1st window, to display a full record, within Page(1) a button opens Page(2), 2nd window, where additional detail information can be entered for record opened in Page(1).

I wonder if I need to name the windows, give Page(1) a name and point my code to that window. If that is the case, how is this done?

Thanks,
 
I'm not sure I understand what your code isn't doing that it should. When you say:

At the time that I click on the button with the above onClick code, I have and show content within the chargeslist tab.

do you mean that the content in the "chargeslist" div changes then you click the button, instead of the content in the "showcharges" div?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
No, I mean that the content is visually there on the page at the time I click on the button.

Pages are produced dynamically and I am wrapping the detailed information within the <div id="chargeslist"></div> tags. The idea is that once the user is done adding details, which is shown on Page(2) as they add an entry, I want to take the content of the Page(2)<div> and plug in within the Page(1)<div> tag, the calling page.

This is what I have

+----------------------------------------------+
| data-grid-page |
| +----------------------------------- + |
| | Page(1) | |
| | +---------------------------+ | |
| | | Page(2) | | |
| | | | | |
| | | | | |
| | +---------------------------+ | |
| | | |
| +------------------------------------+ |
| |
+----------------------------------------------+

So, given this scenario, which is the document.opener as far as Page(2) is concerned?

In summary, I need to take innerHTML from Page(2) and place it in a holder in Page(1) once user clicks on button.

Thanks,

 
If Window 2 is opened using a "window.open" command from Window 1, then I'd say that Window 1 is the opener for Window 2.

Do you see any errors (I advise using the Firebug plugin for Firefox to get better debugging info than IE)?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
I have noticed getting this error
Code:
Error: uncaught exception: [Exception... "Component returned failure code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [nsIFileInputStream.init]"  nsresult: "0x80520012 (NS_ERROR_FILE_NOT_FOUND)"  location: "JS frame :: chrome://firefox/content/firefox.js :: <TOP_LEVEL> :: line 228"  data: no]

I am not sure that it is triggered by my code as it happens in other pages outside those I am working on.

I do use Firebug - Could not work a day without it :cool:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top