473,394 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Method invocation betwee windows.

OK. I have a test html page:

"To.html":

<html>
<head>
<title>To</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script language="JavaScript">
function Go(aString)
{
alert(aString);
return false;
}
</script>
</head>
<body>
<a href="" id="T1" onclick="return window.Go(id);"> <p>T1
anchor</p></a>
<a href="" id ="T2" onclick="return window.Go(id);"> <p>T2
anchor</p></a>
</body>
</html>
</html>

If I press on either the "T1" or the "T2" link, it brings up an alert
with the text set to either "T1" or "T2". Life is good so far.

Now, I use a second window to open the page:

"From.html"

<html>
<head>
<title>From</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script language="JavaScript">
function Go(aString)
{
var vMapWindow = window.open("To.html", "CurrentMap");
vMapWindow.focus();
vMapWindow.Go(aString);
return false;
}
</script>
</head>
<body >
<a href="T1" id="T1" onclick="return window.Go(id)"> <p>T1
anchor</p></a>
<a href="T2" id="T2" onclick="return window.Go(id)"> <p>T2
anchor</p></a>
</body>
</html>

When I press either the "T1" or "T2" links on the "From.html" page,
what is supposed to happen is that the browser is supposed to open a
new window showing "To.html" (which it does), give it the focus (which
it does even without the focus() call, but as I understand it browsers
are not consistent here), and then call the Go() method in the new
window showing "To.html" which should bring up the alert. It doesn't
do this however. In fact, it seems to throw an exception instead,
causing the "From.html" window to attempt to navigate to the
non-existent "T1" or "T2" page.

I am testing this with Safari, but have also tried Firefox and even
old Mac IE 5, and all of them fail the same way so I assume this is
not a browser problem, but a mistake on my part. Anybody know what my
mistake is?
Jul 23 '05 #1
1 1767
Lee
Bowen Simmons said:
function Go(aString)
{
var vMapWindow = window.open("To.html", "CurrentMap");
vMapWindow.focus();
vMapWindow.Go(aString);
return false;
}
</script>


The window.open() method returns without waiting for the window to
actually be opened, so at the time that you're trying to invoke
the Go() method in the new window, it doesn't exist yet.

You can confirm this by making vMapWindow a global variable and
adding a third link that invokes vMapWindow.Go('T3'). Push one
of your links to create the window, then wait for the window to
completely open and press the new link. It will work.

Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Hal Vaughan | last post by:
Being self taught, this is one thing I've always had trouble with -- I finally get it straight in one situation and I find I'm not sure about another. I have a class that keeps calling an...
9
by: Grant Schenck | last post by:
Hello, I have a base class with several derived classes: ScriptBase + ScriptCallInbound + ScriptCallOutbound I then have another class: Line
3
by: Giulio Petrucci | last post by:
Hi there, I'm quite a newbie in Web Service programming/using and I'm sorry if my question could sound quite "stupid". ;-) I'm working on an application which should request a service to a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.