Piotr said:
Hi,
I have a big main window,
Big main window is often referred as opener. Also parent window.
prepared in html, and a small one,
Often referred as secondary window, or child window or sub-window (best
technical term, IMO) or popup window.
opened by
window.open in <script> in main window script.
Make sure you hold, keep a window object reference to that sub-window.
This is highly useful in scripts creating sub-windows; you may want to
re-use, recycle that sub-window or just be able to bring it back in
front of the opener. The general idea is, e.g.
<script type="text/javascript">
var WindowObjectReference;
function OpenRequestedPopup(strUrl, strTarget)
{
if(WindowObjectReference == null || WindowObjectReference.closed)
/*
if the sub-window does not exist or if it was closed, then create it
*/
{
WindowObjectReference = window.open(strUrl, strTarget,
"resizable,status,scrollbars,top=100,left=250,width=400,height=300"
}
else
/*
else just bring the sub-window back in front of the opener
*/
{
WindowObjectReference.focus();
};
}
</script>
And in the html:
<p><a href="path/MyGarden.html" target="ANewSubWindow"
onclick="OpenRequestedPopup(this.href, this.target); return false;"
title="Clicking this link will create a new separate window">See my
garden said:
I would like to click in small one and open sth in main one. How to do it?
Giving an url showing what you have done so far and what are your files
is always more convenient.
There is "target", but how to traget the 1st window?
target is primarly used to target a frame or a sub-window from the opener.
In the sub-window, add this:
<p><button type="button" onclick="if(opener)
{opener.location.href='path/filename.html';};">Load filename in
opener</button></p>
http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/opener.asp
http://www.mozilla.org/docs/dom/domref/dom_window_ref77.html#1019352
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/window.html#1202731
DU