Solved

How to call a javascript function on a page that is NOT the opener.

Posted on 2012-03-21
6
232 Views
Last Modified: 2012-03-27
Hello, I have a page called attach.asp for lack of a better name. Tabs.asp is part of attach.asp.  Attach.asp shows up in the browser URL but tabs.asp does not.  A popup child window is opened from tabs.asp called, popupwin.asp for lack of better name as well.  A function that lives on attach.asp needs to be called from popupwin.asp, but, since the parent opener for popupwin.asp is tabs.asp, I can't call the function on the parent of the parent.

So, I've tried window.opener.functionname() and I get a null object reference.

I've tried parent.window.opener, parent.location.window.opener, and nothing seems to work.

What's bizaar is this tabs.asp window doesn't reside in an iFrame, but is referenced somehow in another way, which I'm still trying to explore.

So does anyone have any thoughts on how to call a function from a child that resides on the parent of an object that's not really there?

Thanks,

P
0
Comment
Question by:pborregg
  • 2
  • 2
  • 2
6 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 37748972
If an object does not exist then it cannot have properties or functions. I have no idea what you are doing it that way but, it will never work.  

Trying to to do cross page scripting is a bad idea about 99% of the time.  Re-consider your design to see if you can get rid of the maze and do things in a straight line.


Cd&
0
 
LVL 82

Expert Comment

by:leakim971
ID: 37748975
>What's bizaar is this tabs.asp window doesn't reside in an iFrame, but is referenced somehow in another way, which I'm still trying to explore.

we need the answer of this question... or give a link to let we answer it.
0
 

Author Comment

by:pborregg
ID: 37749090
It's not my code. I'm working as a contractor with 10,000 pages of code, literally.  It's like finding a needle in a haystack. Unfortunately I cannot give the URL since it's for a US Govt Agency.

I did run this to find the parent and got nothing.

             var origWin = window.opener;
                  try
                  {      
                        if (origWin != null)
                        {
                              alert(origWin.parent.location);
                        }
                   }
                  catch(e)
                  {
                  
                        alert(e.description);
                  
                  }

But it may be in the wrong place in the code... I'll keep at it.  Thanks for your help.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 82

Expert Comment

by:leakim971
ID: 37749217
and what about a small screen copy? Maybe tabs.asp is a CSS popup..
and maybe with an iframe inside
can you move tabs.asp outside attach.Asp
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 500 total points
ID: 37749238
It is possible that the main page closes tab after it opens the popup I might just be using it for a conduit to prevent the popup from accessing the main page.  Having worked on projects for the government it would not surprise me that you are running up against some old security trick that might have been necessary at one time.  I assume ther is little or no documentation.


Cd&
0
 

Author Closing Comment

by:pborregg
ID: 37772617
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
validation, if text area is typed or pasted into 2 25
how would you interpret lines 3 30
how can i count words? 2 18
how can i select 4 9
This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now