Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

top.opener doesn't work in Netscape

Posted on 2003-03-04
8
Medium Priority
?
536 Views
Last Modified: 2007-12-19
Hello,

I have a window that opens another window with two frames. From one of
the frames I'm trying to get elements of the opening window. This code
works well in IE but not in Netscape 4.79. The alert in link_onclick
never shows up, and image_onclick gives an error "top.opener has no
properties".

What am I doing wrong? Thanks.

Julia


<script>
function link_onclick() {
    if ( top.opener ) {
    alert("link_onclick");
        var loc = top.opener.location.href;
        var tit = top.opener.document.title;
        document.add_form.add.value =  ' <A HREF="' + loc + '">' + tit
+ '</A> ';
    }
    document.add_form.submit();
}

function image_onclick() {
   with ( top.opener.document ) {

***more code***
   }
}
</script>


This is the relevant HTML:

<form name="add_form" method=post action="WBedit.pl">
<p>
<table cellspacing=5>
<tr><td><input type=button name=add_link value="Add Link"
onclick="link_onclick();"></td>
<td>Add a link to currently open page.</td></tr>
<tr><td><input type=button name=add_image value="Add Image"
onclick="image_onclick();"></td>
<td>Add a picture from currently open page.</td></tr>
</table>
<input type=hidden name="add">
</form>
0
Comment
Question by:jgenyuk
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 8066434
I wonder why top.opener should ever work.

Top is the root of all windows.
opener is one associated window to the actual window.

That top.opener work is only a error tolerance and you get either top or opener.

Or did you name a frame or window "opener" ???

0
 
LVL 33

Accepted Solution

by:
knightEknight earned 200 total points
ID: 8066585
Actually, top.opener is one of many correct references to the opener.  Most commonly, it is window.opener, but in the case of a frameset in the popup, top.opener is most accurate.

Try this ... when you open the popup, do this:

   var mypopup = window.open( "mypopup.htm", "mypopup", "width=400,height=300" );

   mypopup.opener = self;



This should set the top.opener attribute for the popup.
0
 

Author Comment

by:jgenyuk
ID: 8066614
No, I didn't name anything "opener". That was supposed to refer to the window that opened the  parent window to this frame. Is there another way to do this? Just "opener" doesn't work.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 2

Expert Comment

by:mikkolsoft
ID: 8066710
"..refer to the window that opened the parent window to this frame..."

so I assume it's the window.parent.opener right?
0
 

Author Comment

by:jgenyuk
ID: 8066746
It  is but I'd like to go with "top" because I might add more nested frames later on. I'll try mypopup.opener = self .
0
 
LVL 2

Expert Comment

by:mikkolsoft
ID: 8066801
maybe you just lack a "window" at the front:

window.top.opener

Mikkol
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 8066907
in this case, window.parent == top (from within the frame).  but if there are no frames, then window == top == self.
0
 

Author Comment

by:jgenyuk
ID: 8068099
mypopup.opener = self  works fine, thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…
Suggested Courses

580 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