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!

window.opener IS NOT AN OBJECT -------HELP!!!!!!

Status
Not open for further replies.

ppepin

IS-IT--Management
Mar 13, 2001
36
0
0
US
I have an open window that opens a new window when the user clicks on a button. So far, so good.

In the newly opened window, if the user should select an option, I need to reference the first window using window.opener. This is my code:

<!--
function Resubmit(){
window.opener.rpt_criteria.action=&quot;rpt_results_time.asp?method=export&quot;;
window.opener.rpt_criteria.submit();
MyReset();
}
// -->

This works fine on Windows98 using IE 5.5, but when the same process is done on a Win2k machine running IE 5.0, this function fails with a javascript error stating:

window.opener.rpt_criteria is not an object.

Can anyone help me??????? I am at a complete loss.

Thanks.
 
I'm not an expert at the DOM hierarchy, but you may want to try inserting the document object between opener and your form name, rpt_criteria. As far as I know, &quot;opener&quot; is just another &quot;window&quot; object. So your accessor becomes window.opener.document.rpt_criteria.action ...

If I'm ever baffled as to where in the tree I'm falling off, I usually use alerts to tell me at what point my accessor fails with something like the following:

alert(window);alert(window.opener);alert(window.opener.rpt_criteria)...etc. Each should return [object] in the alert window, a blank alert meaning that that particular object doesn't exist.

Hope that helps,

brendanc@icehouse.net
 
Thanks for your quick response. I will give that stuff a try. I am no expert either as you can tell. I will respond with the results.
 
Well, I tried your suggestions and what I found out is that the alert(window); returned an [object]. That was good.

The alert(window.opener); did NOT return an object. Why is window.opener an invalid object in Win2K??????


Can anyone help me ---- PLEASE!

 
You need to define the parent that you are passing or sending the information to. This is a IE problem.

<script language=&quot;javascript&quot;>
var parentWindow
function setParent(){
parentWindow= top.window.opener
}
function yourFunction(){
parentWindow.location.[your logic]

}
</script>

Also in the body of the pop-up you need to include <body onload=&quot;setParent()&quot;>

Let me know if this helps.
 
NOPE!!!! I tried your script, but this is what I got.

top.window.opener is not an object.

I put in some alerts in at the beginning of the setParent() function:

alert(top); --> returned [object]
alert(top.name); --> returned empty string
alert(top.window); --> returned [object]
alert(top.window.name); --> returned empty string
alert(top.window.opener); --> received &quot;top.window.opener is not an object&quot;

Again, my previous code, as well as your suggested code, works fine in Win95, WinNT and Win98 all using IE 5.5, but will not work in any version of Win2000 using IE 5.0.

Any other suggestions would be appreciated!

Thanks.

 
Well, it appears to be a problem with IE 5.0. I noticed that all the machines it was failing on were running IE 5.0. I upgraded to 5.5 and viola, no more problems.

Funny how MS products work!

Thanks for all your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top