Hi,
I have a big main window, prepared in html, and a small one, opened by
window.open in <script> in main window script.
I would like to click in small one and open sth in main one. How to do it?
There is "target", but how to traget the 1st window?
Thanks,
Peter 5 1237
window.opener
"Piotr" <pi*****@info.com.pl> wrote in message
news:cd**********@news.onet.pl... Hi,
I have a big main window, prepared in html, and a small one, opened by window.open in <script> in main window script. I would like to click in small one and open sth in main one. How to do it?
There is "target", but how to traget the 1st window?
Thanks, Peter
Piotr wrote: 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,widt h=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</a></p>
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.
Thanks, Peter
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/a...ies/opener.asp http://www.mozilla.org/docs/dom/domr...7.html#1019352 http://msdn.microsoft.com/workshop/a...ods/open_0.asp http://devedge.netscape.com/library/...w.html#1202731
DU
"Piotr" <pi*****@info.com.pl> wrote in message
news:cd**********@news.onet.pl... Hi,
I have a big main window, prepared in html, and a small one, opened by window.open in <script> in main window script. I would like to click in small one and open sth in main one. How to do it?
There is "target", but how to traget the 1st window?
Thanks, Peter
This line of script will attch a name to the current window:
top.name="mainwin";
You can add this to the script in the main window and any links in the popup
with target="mainwin" will open in the main window. This way you don't need
script in the popup. You can also refer to the main window from the popup
with "opener". This line of script in the popup:
opener.location.href="nextpage.html";
will open a new page in the opener, regardless of whether or not has a name.
HTH
Ivo
Finally I used <A HREF="javascript:window.opener.location.href=blabl a>
Thank you very much!
Peter
Piotr wrote: Finally I used <A HREF="javascript:window.opener.location.href=blabl a>
That's nonsense, see the FAQ and <http://validator.w3.org/>.
Use
<script type="text/javascript">
function setOpenerLoc(sURI)
{
if (window.opener
&& !window.opener.closed
&& typeof window.opener.location != "undefined")
{
window.opener.location = sURI;
}
return false;
}
</script>
<a href="#"
onclick="return setOpenerLoc('blabla');"...</a>
instead. It would be better if you also wrote that link dynamically so
that users without script support do not encounter "malfunctioning" links:
<script type="text/javascript">
// ...
document.write(
'<a href="javascript :void(setOpenerLoc(\'blabla\'))"'
+ ' onclick="return setOpenerLoc(\'blabla\');">'
+ '...'
+ '<\/a>');
</script>
PointedEars This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bilal |
last post by:
Hi,
I have a web application that operates on several windows. Each window
is named win_1, win_2, win_3,... . When I quit a session, I usually
loop through all the windows and close one by one. So...
|
by: Robert Mark Bram |
last post by:
Hi All!
Is there a way to reference a window by name without doing something like
this:
open (, 'windowName');
The open method will open a blank window if there is no window with such a
name....
|
by: Diana |
last post by:
Hi there,
I'm having some difficulty in renaming a window object. I'm opening
the window in question via a targetted submit:
<!-- CODE EXCERPT FROM WINDOW 1 -->
<form target="newWin">
...
|
by: Tony Farrell |
last post by:
Hi Everyone -
I have a data entry form that allows the user to click a button
and have that button popup a list of available values -
the code on the popup window uses the name of the form
to...
|
by: NeverLift |
last post by:
But, if it's not open, I don't want to open it . . . using
window.open will open it if it doesn't exist, even if the url in that
open is null (the window is then empty -- but it's open).
The...
|
by: Cenekemoi |
last post by:
Hi,
excuse me in advance for my poor english...
Do you know how solve my problem ?
I have "Page1.htm" :
<HTML><BODY>
<A href="Page2.htm" target=TOTO>window TOTO</A>
|
by: er441298 |
last post by:
we are upgrading an application which is JS heavy to run on IE6. When
in IE 5.0, and when the following command is executed on a child
window (top.window.name), it returns an actual window ID ( a...
|
by: Ryan |
last post by:
Greetings,
I would like to know if I can name my main browser window so that I can link
back to it from a pop-up window. I know using <A HREF="url" TARGET="name">
will name the new window being...
|
by: multicherry |
last post by:
Hi,
Having searched for a way to fetch a window object by name, all I came
across were answers along the line of...
"All you have to do is say windowObj = window.open("blah", "name");"
which...
|
by: mikewse |
last post by:
I'm having a strange problem with window.name (from JavaScript) on *some* of our computers. OS is Windows 2000 so Internet Explorer version is IE6 sp1. I really need some help here...
We are using...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |