JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 22nd, 2001, 07:13 AM
tforde tforde is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Halifax Nova Scotia Canada
Posts: 5 tforde User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to tforde
Question Javascript Print()

I have a page divided up into two frames. The top frame contains information, while the bottom frame contians my navigation buttons and a print button. When a user clicks on the print button I have it set up to print the top frame. This works fine except that it closes the window when the printing starts. Does anyone know why it does this. I don't want the window to close. I do not have any code in there to cause the window to close. The print button is set up like this.

<input type=image src="Graphics/print.jpg" name=cmdprint value=Print onClick=top.frames[0].CallPrint() border=0>

In my top frame I have set up the following function.

function CallPrint()
{
self.focus()
self.print()
}

none of this script should close the window. Does anyone know if it is a bug of javascript, or is there something else happening.

Reply With Quote
  #2  
Old June 22nd, 2001, 08:28 AM
Void Void is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: The Netherlands
Posts: 200 Void User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to Void
Which OS/browser/version?

Nothing in the refs on print doing anything dirty.

How about that self.focus() ?
Hmm, nah, probably nothing wrong with that either.
It's close that doesn't work on individual frames, focus should work just fine.

You're not using a print _button_ btw.

Do you have "Display a notification about every script error" turned on?

Reply With Quote
  #3  
Old June 22nd, 2001, 08:36 AM
tforde tforde is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Halifax Nova Scotia Canada
Posts: 5 tforde User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to tforde
Browser IE 5.5, haven't tried netscape 6 yet.

I am just using a regular image button, the client did not want the buttons to display on the print out page, that is why I am using frames. I place my buttons on the bottom frame to control the top frame. So that when they print only the contents of the top frame gets printed. The focus is there for older browsers, I read that for IE 4 and Mac IE 4, the frame you want to print has to recieve focus first.

I do have display notification turned on, but it is not returning anything, that is why I am stumped. It almost seems that the window is tied into the print window. Because when I hit cancel on the print window, that closes my browser as well. It is really wierd.

Reply With Quote
  #4  
Old June 22nd, 2001, 08:46 AM
Void Void is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: The Netherlands
Posts: 200 Void User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to Void
What happens if you try to print a normal webpage through File >> Print?

What's in your File >> Page Setup.. ?

Have you tried printing a normal webpage (no frames) with window.print()?

Having some doubts about that self.print(). What exactly is self referring to? Ah, to the window I guess. Well, you could try window.print() instead, but I don't think there's a difference.

Reply With Quote
  #5  
Old June 22nd, 2001, 08:51 AM
tforde tforde is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Halifax Nova Scotia Canada
Posts: 5 tforde User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to tforde
There is a difference between window.print() and self.print()

Window.print() will print the entire window. Including the bottom frame with the buttons. self.print() prints just the frame with the focus. It is the same as saying top.frames[0].print().

I have tried a left click and print on the frame window and that worked fine. It is just the javascript one that does it. I have also tried a simple test page with a self.print() no frames, and again it worked just fine. It is just this frames page.

Reply With Quote
  #6  
Old June 22nd, 2001, 09:06 AM
Void Void is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: The Netherlands
Posts: 200 Void User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
Send a message via ICQ to Void
Does this work:

Put this function in the onClick of your Print button

function myprint()
{
window.parent.frames[0].focus();
window.print();
}


(yes, I know you said that window.print prints the entire window, but it really shouldn't do this cause your frame == window)

-------------
I found some examples on the net and they all say that if you want to print frame B, you have to call the print function from frame A. Doesn't make any sense to me, but perhaps that is what's causing your problem.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Javascript Print()


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT