473,785 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

when is my window ready ?

It seems as though when I use window.open I can't immediately do

winId.document. getElementById( "someDivTagInTh eWindow")

because window.open returns to my code before the html in the window
is really loaded.

What is a good way to synchronize, in other words to have my code know
when the window is ready to be interrogated ?

Thanks. er*******@rcn.c om
Jul 23 '05 #1
4 7411
In article <39************ **************@ posting.google. com>,
er*******@rcn.c om enlightened us with...

What is a good way to synchronize, in other words to have my code know
when the window is ready to be interrogated ?


Have the new window run script onLoad telling opener that it loaded.

--
--
~kaeli~
I can't sleep.
The clowns might eat me.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
kaeli <ti******@NOSPA M.comcast.net> wrote in message news:<MP******* *************** **@nntp.lucent. com>...
In article <39************ **************@ posting.google. com>,
er*******@rcn.c om enlightened us with...

What is a good way to synchronize, in other words to have my code know
when the window is ready to be interrogated ?


Have the new window run script onLoad telling opener that it loaded.

--

What are you proposing as an easy way for "telling opener" . If I
put

<body onLoad="HiImRea dy();">

the HiImReady function has to be in the html running in the new
window, but how can I call a function back in the html whose script
did the window.open ? (or did you mean something else entirely ???)
Jul 23 '05 #3
In article <39************ **************@ posting.google. com>,
er*******@rcn.c om enlightened us with...
kaeli <ti******@NOSPA M.comcast.net> wrote in message news:<MP******* *************** **@nntp.lucent. com>...
In article <39************ **************@ posting.google. com>,
er*******@rcn.c om enlightened us with...

What is a good way to synchronize, in other words to have my code know
when the window is ready to be interrogated ?


Have the new window run script onLoad telling opener that it loaded.

--

What are you proposing as an easy way for "telling opener" . If I
put

<body onLoad="HiImRea dy();">

the HiImReady function has to be in the html running in the new
window, but how can I call a function back in the html whose script
did the window.open ? (or did you mean something else entirely ???)


The opener has a global variable. Call it childIsOpen.

var childIsOpen = false;

The opener has a function to set that variable. Call it setChildIsOpen.
function setChildIsOpen( b)
{
childIsOpen = b;
return;
}

The child then tells the opener it loaded.
<body onLoad="window. opener.setChild IsOpen(true)">

The opener can then test that variable as
if (childIsOpen)
{
// whatever
}

Works in theory.

Let me test it and see...
Okay, this worked fine in IE. Test in any other browsers you'd like.

----------------------------------
test3.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title> New Document </title>
<script type="text/javascript">
var childIsOpen = false;

function setChildIsOpen( b)
{
childIsOpen = b;
return;
}

function openChild()
{
window.open("te st4.html","","t oolbars=no,widt h=100,height=10 0");
setTimeout("tes tChild()",1000) ;
}

function testChild()
{
if (childIsOpen)
alert("open!");
else
alert("nope!");
}
</script>
</head>

<body>
<form>
<input type="button" value="Click to open" onClick="openCh ild()">
</form>
</body>
</html>

-------------------------------

test4.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title> New Document </title>
<script type="text/javascript">
</script>
</head>

<body onLoad="window. opener.setChild IsOpen(true)">
test
</body>
</html>
--
--
~kaeli~
The man who fell into an upholstery machine is fully
recovered.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #4
kaeli <ti******@NOSPA M.comcast.net> wrote in message news:<MP******* *************** **@nntp.lucent. com>...
In article <39************ **************@ posting.google. com>,
er*******@rcn.c om enlightened us with...
kaeli <ti******@NOSPA M.comcast.net> wrote in message news:<MP******* *************** **@nntp.lucent. com>...
In article <39************ **************@ posting.google. com>,
er*******@rcn.c om enlightened us with...
>
> What is a good way to synchronize, in other words to have my code know
> when the window is ready to be interrogated ?
>
>

Have the new window run script onLoad telling opener that it loaded.

--

What are you proposing as an easy way for "telling opener" . If I
put

<body onLoad="HiImRea dy();">

the HiImReady function has to be in the html running in the new
window, but how can I call a function back in the html whose script
did the window.open ? (or did you mean something else entirely ???)


The opener has a global variable. Call it childIsOpen.

var childIsOpen = false;

The opener has a function to set that variable. Call it setChildIsOpen.
function setChildIsOpen( b)
{
childIsOpen = b;
return;
}

The child then tells the opener it loaded.
<body onLoad="window. opener.setChild IsOpen(true)">

The opener can then test that variable as
if (childIsOpen)
{
// whatever
}

Works in theory.

Let me test it and see...
Okay, this worked fine in IE. Test in any other browsers you'd like.

----------------------------------
test3.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title> New Document </title>
<script type="text/javascript">
var childIsOpen = false;

function setChildIsOpen( b)
{
childIsOpen = b;
return;
}

function openChild()
{
window.open("te st4.html","","t oolbars=no,widt h=100,height=10 0");
setTimeout("tes tChild()",1000) ;
}

function testChild()
{
if (childIsOpen)
alert("open!");
else
alert("nope!");
}
</script>
</head>

<body>
<form>
<input type="button" value="Click to open" onClick="openCh ild()">
</form>
</body>
</html>

-------------------------------

test4.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title> New Document </title>
<script type="text/javascript">
</script>
</head>

<body onLoad="window. opener.setChild IsOpen(true)">
test
</body>
</html>
--

Thanks for doing that !

The crux which I seemed to have been missing before is the whole
ability to have the script in the new window have the ability to
"reach back" into its caller space by saying

window.opener ...

That's a real eye opener.

Thanks.

/Eric
Jul 23 '05 #5

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

Similar topics

6
3355
by: Coral Snake | last post by:
I am having problems with programming even simple "Hello World" programs from books and tutorials that use Python GUI libraries. Such Programs cause python to throw "Attribute Errors" even when the "attributes" being asked for by the errors exist in the source code. This has happened to me in both the standard python GUI Library Tkinter and in pyGTK here are the codes for the "Hello World Programs involved and their corosponding "Attribute...
26
2479
by: Simon | last post by:
I'm doing a survey. When do you think GNU/Linux will be ready for the average Joe? What obstacles must it overcome first?
2
7882
by: Reply Via Newsgroup | last post by:
Folks, I was sure this could be done - or at least sure I had seen reference to it at some point or other - but now, after having gone for a cup of tea, am begining to doubt my original belief. Can I have a script, available in a parent function, called from a child window? If so, how? And... if so, why? I mean, while sipping my tea, I realised that if the
3
1368
by: Christopher Benson-Manica | last post by:
I have a situation where a bit of script needs to pop up another window, and then call a script in that new window. My conundrum is that the script should not be called until the new window has rendered completely. What's the best way for the new window to tell its opener that it is fully rendered? The thought that occurs to me is having a script at the bottom of the new window that calls a script in the openening window that then calls...
31
2853
by: Benno Bös | last post by:
If I use the following construct in the frame "main" for a link to an extern site: <A HREF="http://www.any.xy" TARGET="extern"> the Browser is creating the window "extern", loading the page www.any.xy an setting the focus to "extern". But when I go return to "main" without closing "extern", a click to an other link (e.g. www.2nd_any.xy) on "main" does not setting the focus to "extern".
4
2664
by: Jake Lewis | last post by:
I have an HTML page that loads fine including the .js file <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> <script language="JavaScript" type="text/JavaScript" src="ve3d.js" ></script> </head>
4
2144
by: Chuck Tomasi | last post by:
I'm clearly missing something and I've been looking for a solution for hours without a clue. Objective: Create a typical "download" link using JS window.open. I get the window to open, the "Save As" box appears, and the file ends up where I want it, with the right name, the problem is that the child window doesn't go away (save IE). Mozilla Firefox (PC and Mac), Safari, and all others I've tested leave the child window. If I do a...
5
4050
by: Homa | last post by:
Hi all, Can anyone give me some links about how to do an async web service call from aspx and display a temperary page before the web service returns? Thanks, Homa Wong
4
3409
by: Markus Stoeger | last post by:
Hi, I have a problem with Application.Run() when Windows is shutting down. Please have a look at the copy&paste example program below. The application has no forms. It has only got a notify icon in the system tray and it uses Application.Run() to keep the message loop running. When the user clicks the icon, the application should shut down and exit. So far that works fine.
0
9481
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10155
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10095
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9954
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7502
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5383
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.