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

Home Posts Topics Members FAQ

window.onload being ignored for child in IE

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(l oc)
{
var printWin = window.open(loc +'?
dl=false','prin tpage','width=6 00,height=800,l ocation=no,menu bar=no,director ies=no,status=n o,toolbar=no,sc rollbars=yes,re sizable=yes');
printWin.onload = function()
{
printWin.print( );
}
}

Even if I just put an alert in that printWin.onload , it doesn't do
anything. My only guess is that the page has loaded before the onload
function gets assigned, but I can't figure out a way to assign it
otherwise.
Jun 27 '08 #1
2 2243
On Jun 12, 5:28 pm, Beni Rose wrote:
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(l oc)
{
var printWin = window.open(loc +'?
<snip>
printWin.onload = function()
{
printWin.print( );
}

}

Even if I just put an alert in that printWin.onload , it doesn't
do anything. My only guess is that the page has loaded before
the onload function gets assigned, but I can't figure out a way
to assign it otherwise.
In reality IE assigns an onload value as a page loads and when that
page does not define an onload handler of its own (is a script or as
an attribute in the opening body tag) it ends up assigning the null
value to onload. Thus you just cannot successfully assign to the
onload property of the object returned from - window.open -.
Jun 27 '08 #2
SAM
Beni Rose a écrit :
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(l oc)

perhaps ... :
function openPrintPage(l oc)
{
var attr = 'width=600,heig ht=800,'+
'location=no,me nubar=no,direct ories=no,'+
'status=no,tool bar=no,scrollba rs=yes,resizabl e=yes'
if(typeof printWin == 'undefined' || printWin.closed )
{
printWin = window.open('', '',attr);
}
printWin.onload = printWin.print; // or = window.print;
printWin.locati on = loc+'?dl=false' ;
}

--
sm
Jun 27 '08 #3

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

Similar topics

4
7411
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 ?
2
7631
by: Richard Bell | last post by:
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.attachEvent( "onload", myfunc);
5
2861
by: Hemanth | last post by:
Hello there, I'm running a script that opens a popup window (which is basically a form with checkboxes and a submit button). When I click the submit button I want to run a PHP script and target the result to main page (I mean, update the parent page). My popup form looks like this: <form name="form1" action="run.php" method="get" target="???">
1
4999
by: Paul D. Fox | last post by:
I'm trying to launch a Child Window from a hyperlink on a Datagrid and have it recieve multiple values from the Parent Window. Upon recieving the values in the Child Window, I need to access them in the code-behind so I can render a datagrid in the Child. I've tried just doing another Postback in the child's onLoad event but I get a Javascript error. Is there another way to do this? <%@ Page Language="vb" AutoEventWireup="false"...
1
1961
by: Bill Borg | last post by:
Hello all, Simple chat app, where the site owner has a master window with all requests for chat, status of each room, etc., and child windows for each separate chat in which the owner is engaged. When the owner closes one of his child windows, I want to update the master window. I understand "reasonably" well how to go about this. The master window launches the children, and maintains an associative array to keep track of each one....
7
2513
by: Jaggu | last post by:
Hi , I need to close main window, once the child window succesfully opens else main window to remain. In my case when I close the main window immediately after the "window.open()" as mentioned below, both the main and child disappears(this is due to pop up blocker) disappears suddenly. I want to make the browser know if pop up blocks the child window(in case). help me how to check the child window opened successfuly or not, on
6
19320
by: Daz | last post by:
Hello everyone, I would like to open a child window from the parent, and add an onload event listener to the child window which will tell the parent when the document has loaded. As far as I know, this shouldn't be an issue, but I just can't get it to work. The script only needs to work with Firefox/Mozilla, so XP code isn't an issue. I have tried to open a window like so.
1
2473
by: Socrates | last post by:
Hi - Have tried for half and hour to get this script to work: I am trying to close the parent window while opening a centred new child window I would be grateful if someone could correct the script below which does open a new window, but not in a centred position. Here is the link to the url:
3
7368
by: Jimmy | last post by:
It is also possible for popup window to call function in main window by using the opener property. Will "opener.someFunctionInMain(param1, param2)" in the popup window work? It's possible for main window to call function in the popup window, right? The following is a sample code (close popup window causes to show alert window) which doesn't seems to work. Can anyone see the problem? // main
0
9645
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, 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...
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
10341
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, 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...
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...
0
8979
agi2029
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...
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
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
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...
2
3656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.