I'm a bit new to Javascript and am trying to do
oNewWin = window.open( ... );
then determine when the contents of oNewWin are completely loaded.
I've tried
oNewWin.attachE vent( "onload", myfunc);
but that doesn't work.
Can something of this sort be done? 2 7632
Richard Bell wrote: I'm a bit new to Javascript and am trying to do
oNewWin = window.open( ... );
then determine when the contents of oNewWin are completely loaded.
I've tried
oNewWin.attachE vent( "onload", myfunc);
but that doesn't work.
Can something of this sort be done?
Create a dummy document as follows:
--dummy.html--
<html>
<head>
<title>dummy.ht ml</title>
</head>
<body onload="
if (window.opener && window.opener.c allBack) {
window.opener.c allBack();
}
">
</body>
</html>
Then structure your script to open the new window as follows:
<script type="text/javascript">
function callBack() {
alert('The new window has finished loading!');
}
oNewWin = window.open('du mmy.html', 'theName', '...');
</script>
If you don't like the idea of creating dummy.html on your file system,
you could use:
var newDocument = [
'<html>',
'<head>',
'<title>dummy.h tml</title>',
'</head>',
'<body',
' onload="if (window.opener && window.opener.c allBack)',
' window.opener.c allBack();">',
'</body>',
'</html>'
].join('\n');
oNewWin = window.open('ja vascript:newDoc ument', 'theName', '...');
All the usual warnings about popups apply (they may not be available,
they may be available but not do what you expect, they may open as new
tabs in an existing browser window, etc).
--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq
On Wed, 20 Oct 2004 17:06:20 GMT, Grant Wagner
<gw*****@agrico reunited.com> wrote: Create a dummy document as follows:
--dummy.html-- <html> <head> <title>dummy.h tml</title> </head> <body onload=" if (window.opener && window.opener.c allBack) { window.opener.c allBack(); } "> </body> </html>
Then structure your script to open the new window as follows:
<script type="text/javascript"> function callBack() { alert('The new window has finished loading!'); } oNewWin = window.open('du mmy.html', 'theName', '...'); </script>
Unfortunately, I need to load an arbitrary URL that I've no control
over, thus I was hoping to sit on the child window's onload event or
something similar. I did find a frame approach that works for many,
but alas not all ... about a 6% failure rate, URLs and am searching
for a more robust solution.
Is anyone aware of an approach that doesn't depend on frames or having
access to the childs HTML content?
In a somewhat related question, how do I tell that the child has
created a child (popup) window of its own?
Thanks If you don't like the idea of creating dummy.html on your file system, you could use:
var newDocument = [ '<html>', '<head>', '<title>dummy.h tml</title>', '</head>', '<body', ' onload="if (window.opener && window.opener.c allBack)', ' window.opener.c allBack();">', '</body>', '</html>' ].join('\n'); oNewWin = window.open('ja vascript:newDoc ument', 'theName', '...');
All the usual warnings about popups apply (they may not be available, they may be available but not do what you expect, they may open as new tabs in an existing browser window, etc). This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: alanstew |
last post by:
With the body tag calling out 'window onload', a function with a
'window.open' fails at the 'window.open' line. If I cut out the body
tag, the function executes as normal.
At first I thought it was the entire function failing, but I tested
with alerts and found that it was only the 'window.open' that fails to
execute.
The function is being called by a link, and I suspected some problem
with the body alink/vlink but after cutting that out...
|
by: Eric Osman |
last post by:
It seems as though when I use window.open I can't immediately do
winId.document.getElementById("someDivTagInTheWindow")
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 ?
|
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 situation is: A main window opens child windows one at a time as
the user requests, each with its own name. The user may click in any
child window or the main window to open a summary window, which has a
name all windows know. I want to get that...
|
by: Jenny |
last post by:
In the code below, I can write html content var t='<body
BGCOLOR=blue>'
for a new window. But if it contains javascript, such as var
t='<body onload="window.open('new1.html')">', this code will not work.
Could you confirm this and find such syntax rule for me on the
internet? Thank a lot.
<html><head>
</head><body>
<SCRIPT language=JavaScript>
|
by: Beni Rose |
last post by:
I'm trying to open a new window using window.open and then print that
window once it's loaded. It works fine in Firefox, but not at all in
IE. No matter what I put in my onload, it gets ignored. Here's the
code:
function openPrintPage(loc)
{
var printWin = window.open(loc+'?
dl=false','printpage','width=600,height=800,location=no,menubar=no,directories=no,status=no,toolbar=no,scrollbars=yes,resizable=yes');
printWin.onload = function()
| |
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |