View Full Version : loading page in parent window from pop-up
webtekie
11-05-2002, 11:39 AM
Hello,
I have a page that loads a pop-up when 'submit' is pressed in html form. The pop-up window contains a hyperlink, I want that hyperlink to load in the parent page not the pop-up. I tried including target="_parent" in my <a href>, but it does not work. I guess it thinks that parent is the pop-up? What should I do?
Also, I submit my form like this:
<form method="POST" name="searchMenu" action="smm2.jsp" target="_blank" onSubmit="return(checkField())">, this loads a page in a new window, but with all the title bars and the buttons. How do I submit a form so that I can control how the new window appears?
thanks,
webtekie
kdjoergensen
11-05-2002, 11:55 AM
If a popup is opened using the window.open() method an object reference is created in the popup window through the 'opener' property which refer back to the main window. You can access this property object via script.
I am not sure if your cgi script creates this link, but you can try this:
In the small window:
<script language="javascript">
function mainOpen(thisPage){
self.opener.location.href = thisPage;
}
</script>
<a href="mainOpen('http://www.mydomain.com/index.html')">Home</a>
webtekie
11-05-2002, 12:09 PM
Hmm...did not work. Besides, when you say: self.opener.location.href = thisPage;, doesn't self refer to the pop-up window?
kdjoergensen
11-05-2002, 05:28 PM
Yes, thanks for noticing..
but as mentioned, when a popup (child) window is opened by a main window, the popup's own OPENER property is set with a reference to the main window.
e.g. in the popup window:
'window' refer to the popup itself
'window.opener', 'self.opener' refers to the window that opened it..
e.g. self.opener.location.href is the same as writing:
"myparentwindow.location.href" (where parent window is the main window which launched the child window).
I think the problem you have is that popup is not being opened by javascript and thus there is not 'opener' property defined in the child window (you can check this by writing: alert(self.opener); ). If an opener is defined you will get an alert like this: [Object object]
You probably need to make the change in your cgi program to converse through the popup window. Without an object reference link between the two windows you can not talk between them...
webtekie
11-05-2002, 05:42 PM
yeah, I think that's exectly what happend. Before I was opening a new window thru HTML's submit button, but now I do it thru javascript and everything works fine.
thanks,
webtekie
Jon Hanlon
11-05-2002, 05:43 PM
Why doesn't your CGI or JSP or whatever load the new page?
That's the traditional way of doing things.
webtekie
11-05-2002, 05:52 PM
it was loading the page, but when I used 'window.opener' object, I would get a JavaScript error complaining about this object not being valid. So, I made JavaScript take care of form submission and specifying action attribute for the form.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.