473,406 Members | 2,849 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,406 software developers and data experts.

Problem printing popup pages.

gb
Hi All,

Ive created a popup page using 'var openWindow = window.open("new","pop")'

And added content using openWindow.document.write(" "); statements. But now
I would like to be able to print this page?

openWindow.document.write("<a href='#'
onClick='self.close()'>Close<\/a><\/p>")

This closes the page but these lines below only print the parent page not
the popup child window.

openWindow.document.write("<a href='#'
onClick='self.print()'>Print<\/a><\/p>")
openWindow.document.write("<a href='#'
onClick='window.print()'>Print<\/a><\/p>")

Ive also been trying to write a function based on document.lastChild:

popupPrint()

var popUp = document.lastChild;
popUp.print();
}

But nothing works?

Any help appressiated i'm using IE5.5 if this has an effect?

Regards

gb
Jul 20 '05 #1
16 10372
gb hu kiteb:
Hi All,

Ive created a popup page using 'var openWindow =
window.open("new","pop")'

And added content using openWindow.document.write(" "); statements.
But now I would like to be able to print this page?


Why do you even assume that the machine viewing your web page has a
printer attached?
--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #2
<a href="javascript:onClick=window.print()">print</a> should work.

Regards
Lee

"gb" <gb@tinyworld.co.uk> wrote in message
news:3f********@mk-nntp-2.news.uk.tiscali.com...
Hi All,

Ive created a popup page using 'var openWindow = window.open("new","pop")'
And added content using openWindow.document.write(" "); statements. But now I would like to be able to print this page?

openWindow.document.write("<a href='#'
onClick='self.close()'>Close<\/a><\/p>")

This closes the page but these lines below only print the parent page not
the popup child window.

openWindow.document.write("<a href='#'
onClick='self.print()'>Print<\/a><\/p>")
openWindow.document.write("<a href='#'
onClick='window.print()'>Print<\/a><\/p>")

Ive also been trying to write a function based on document.lastChild:

popupPrint()

var popUp = document.lastChild;
popUp.print();
}

But nothing works?

Any help appressiated i'm using IE5.5 if this has an effect?

Regards

gb

Jul 20 '05 #3
Hmmm, didn't think that was fair... 3 x three worded reasons:

User enhanced experience
Useability and accessibility
Human Centered Interfaces...

Should always assume that a person has peripherals attached and design to
cover... a printer being the most basic and common.

Regards

Lee
"Fabian" <la****@hotmail.com> wrote in message
news:bp*************@ID-174912.news.uni-berlin.de...
gb hu kiteb:
Hi All,

Ive created a popup page using 'var openWindow =
window.open("new","pop")'

And added content using openWindow.document.write(" "); statements.
But now I would like to be able to print this page?


Why do you even assume that the machine viewing your web page has a
printer attached?
--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #4
"Lee Mundie" <le**********@ntlworld.com> writes:

Please don't top post.
<a href="javascript:onClick=window.print()">print</a> should work.


The "onClick=" is not needed, and in fact does nothing except create
a new global variable.

You should not use javascript:-URLs. I recommend using a button
<input type="button" value="Print!" onclick="window.print()">
If you insist on using a link, give it a meaningful href, but use
the onclick handler for javascript:
<a href="YouNeedJavascript.html" onclick="window.print();return false;">
Print!</a>

(in "YouNeedJavascript.html" you explain why your page only works well
with Javascript enabled).

Even if you write the a-element with Javascript, you should use the
onclick attribute. It doesn't have the potential, often unexpected,
side effects of javascript:-URLs (like clearing the page if the
Javascript expression doesn't evaluate to undefined).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #5
Lee Mundie wrote on 22 Nov 2003:
Hmmm, didn't think that was fair... 3 x three worded reasons:

User enhanced experience
Useability and accessibility
Human Centered Interfaces...

Should always assume that a person has peripherals attached and
design to cover... a printer being the most basic and common.


But in this case, you don't need to cover such a need. If a user
wants to print a page, they can use their browser's 'Print' command.
That's what it's there for and what I look for - not whether the
author was "kind" enough to provide a button or link.

Mike

And don't top post.

--
Michael Winter
M.******@blueyonder.co.uk.invalid (remove ".invalid" to reply)
Jul 20 '05 #6
Lee Mundie hu kiteb:
Hmmm, didn't think that was fair... 3 x three worded reasons:

User enhanced experience
Useability and accessibility
Human Centered Interfaces...

Should always assume that a person has peripherals attached and
design to cover... a printer being the most basic and common.


If someone has a printer, chances are they are able to print from the
web browser just fine using the normal browser interface. Why reinvent
something that already exists?

And if the browser was such that printing was not possible even assuming
a printer is attached, then surely javascript would also fail as a
solution?

I suppose the point is that you want to be able to print this window
while still having the usual window interface hidden. This is one of the
big reasons popup windows are hated - the interface is often hidden. But
there is still control-P, or the best solution - no popups, or, if you
must have popups, don't hide the interface.
--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #7
DU
Michael Winter wrote:
Lee Mundie wrote on 22 Nov 2003:

Hmmm, didn't think that was fair... 3 x three worded reasons:

User enhanced experience
Useability and accessibility
Human Centered Interfaces...

Should always assume that a person has peripherals attached and
design to cover... a printer being the most basic and common.

But in this case, you don't need to cover such a need. If a user
wants to print a page, they can use their browser's 'Print' command.
That's what it's there for and what I look for - not whether the
author was "kind" enough to provide a button or link.

Mike

And don't top post.


I agree with the above. Nevertheless, there could be several reasons to
create a custom stylesheet for printing.

1- remove webpage background color
2- display url values (hypertext links) and not text of links in the
printed form
3- control page break
4- control font size

So far, no one in this thread mentioned that.

CSS Design: Going to Print
http://www.alistapart.com/articles/goingtoprint/

DU
Jul 20 '05 #8
DU
Fabian wrote:
Lee Mundie hu kiteb:

Hmmm, didn't think that was fair... 3 x three worded reasons:

User enhanced experience
Useability and accessibility
Human Centered Interfaces...

Should always assume that a person has peripherals attached and
design to cover... a printer being the most basic and common.

If someone has a printer, chances are they are able to print from the
web browser just fine using the normal browser interface. Why reinvent
something that already exists?


Printer friendly version of a document or a document selection might be
a reason to create a custom stylesheet for printing though.
And if the browser was such that printing was not possible even assuming
a printer is attached, then surely javascript would also fail as a
solution?

I suppose the point is that you want to be able to print this window
while still having the usual window interface hidden. This is one of the
big reasons popup windows are hated - the interface is often hidden. But
there is still control-P, or the best solution - no popups, or, if you
must have popups, don't hide the interface.


Printing a selection of a document can be difficult or not working
(e.g.: Opera 7.x). Highlighting abs. positioned elements in MSIE 6 for
windows is difficult, e.g. a column in a 3 column webpage document.

I agree overall with what you say. I just see a few precise, specific
instances where printing from a requested popup might be needed or might
be a responsible webdesign decision.

DU

Jul 20 '05 #9
DU <dr*******@hotWIPETHISmail.com> writes:
Michael Winter wrote: ....
If a user wants to print a page, they can use their browser's
'Print' command.

.... I agree with the above. Nevertheless, there could be several reasons
to create a custom stylesheet for printing.


Sure, but that doesn't require a new print button. Just add the
stylesheet with media="print", and it is only used for printing.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #10
DU hu kiteb:

I agree with the above. Nevertheless, there could be several reasons
to create a custom stylesheet for printing.

1- remove webpage background color
I think all the major web browsers, those that are able to display
backgrounds anyway, include a built in option to strip background
colours when printing.
2- display url values (hypertext links) and not text of links in the
printed form
I wasn't aware stylesheets alone could do this.
3- control page break
4- control font size


Since you have no way of knowing what paper size they are using, or how
good the guy's eyesight is, forcing page breaks or font size is a VERY
bad idea.

--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #11
JRS: In article <IB********************@newsfep2-win.server.ntli.net>,
seen in news:comp.lang.javascript, Lee Mundie
<le**********@ntlworld.com> posted at Sat, 22 Nov 2003 22:40:38 :-

If you read the newsgroup FAQ, you can find out how responses should be
formatted; if you heed this, people will not feel the need to write
"Please don't top-post", "Please don't over-quote", etc.; and will be
more likely to answer what you want.
Hmmm, didn't think that was fair... 3 x three worded reasons:

User enhanced experience
Useability and accessibility
Human Centered Interfaces...

Should always assume that a person has peripherals attached and design to
cover... a printer being the most basic and common.


If you are dealing with a Company Intranet, you may be entitled to
assume that the material *must* be printed, and that a printer *will* be
connected. Even then, will it necessarily have the right sort of paper?

I have a printer connected, but not turned on; and I would not want you
to be able to choose to waste my ink and paper.

Printing without explicit user assent from a Web page should be
impossible.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #12
DU
Fabian wrote:
DU hu kiteb:
I agree with the above. Nevertheless, there could be several reasons
to create a custom stylesheet for printing.

1- remove webpage background color

I think all the major web browsers, those that are able to display
backgrounds anyway, include a built in option to strip background
colours when printing.


Correct.
2- display url values (hypertext links) and not text of links in the
printed form

I wasn't aware stylesheets alone could do this.


a:link:after { content: " (" attr(href) ") "; }
3- control page break
4- control font size

Since you have no way of knowing what paper size they are using, or how
good the guy's eyesight is, forcing page breaks or font size is a VERY
bad idea.


For font size, you may be right. The user can still override the
author's suggested font-size value with the browsers' page setup (Print
preview in MSIE 6) printing options. I checked NS 7.1, Mozilla 1.5, MSIE
6 for windows and Opera 7.23 and they all allow users to scale the font
size in %percentage of the author's font-size. I did not test this though.

Regarding page break, I was thinking about all the page media style
properties. These are quite useful. Let's say you have a big table (or a
big element like an image) and you do not want it to be broken on 2
pages: then page-break-before is useful. Currently, Opera 7.x, NS 7.x
and Mozilla 1.3+ support page-break-before.

http://www.westciv.com/style_master/.../printing.html

Such style sheet is still an author stylesheet. Users can still control
a few properties via page setup or print preview dialog boxes. I must
say I need to test all this.

I think everyone who replied that there was no need for javascript to
print a page was correct. I just think it was more according to the
spirit of usability to suggest to the original poster to work on
creating a custom stylesheet for printing.

DU

Jul 20 '05 #13
DU hu kiteb:
Fabian wrote:
DU hu kiteb:
2- display url values (hypertext links) and not text of links in the
printed form

I wasn't aware stylesheets alone could do this.


a:link:after { content: " (" attr(href) ") "; }


I just tested this; it doesn't appear to work, or does it only have the
expected effect when printing to a printer, and not to a screen? Where
is the reference for this? I agree this would be VERY useful if it
consistently worked across environments.
--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #14
DU
Fabian wrote:
DU hu kiteb:

Fabian wrote:
DU hu kiteb:
2- display url values (hypertext links) and not text of links in the
printed form
I wasn't aware stylesheets alone could do this.

a:link:after { content: " (" attr(href) ") "; }

I just tested this; it doesn't appear to work, or does it only have the
expected effect when printing to a printer, and not to a screen?


You should see the link values in the print preview window.

Where is the reference for this?
See
http://www.alistapart.com/articles/goingtoprint/

I agree this would be VERY useful if it consistently worked across environments.

The following documents are valid, validated, tested (printed) and
working for Mozilla 1.5, K-meleon 0.8 (build 844), NS 7.1, Opera 7.23.
Opera 7.23 had the best printed rendering (no extra blank spaces like
Mozilla does). MSIE 6 for windows did not render the link values at all.

DU

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

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html lang="en-us">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">

<title>Testing custom print stylesheet</title>

<link rel="stylesheet" type="text/css" href="print.css" media="print">

</head>

<body>

<p>A few sites to visit:</p>

<ul>
<li><a href="http://www.lajzar.co.uk">Fabian's site</a></li>
<li><a
href="http://www.westciv.com/style_master/academy/browser_support/printing.html">Browser
support for CSS2 properties in media print</a></li>
<li><a href="http://www.alistapart.com/articles/goingtoprint/">CSS
Design: Going to Print</a></li>
<li><a href="http://validator.w3.org/">W3C HTML validation</a></li>
<li><a href="http://checkie.orange-soft.com/index.htm">Multi-validator
plug-in for MSIE (Spanish)</a></li>
</ul>

</body></html>

print.css
---------

a:link:after, a:visited:after {content: " ( " attr(href) " )";}
Jul 20 '05 #15
"Fabian" <la****@hotmail.com> writes:
DU hu kiteb:
Fabian wrote: a:link:after { content: " (" attr(href) ") "; }
I just tested this; it doesn't appear to work, or does it only have the
expected effect when printing to a printer, and not to a screen?


The part you quoted can work at any time. If it is wrapped in a
@media print { ...}
or included with
<link rel="stylesheet" media="print" ...>
then it only affects the printed media.

That line alone only puts content after unvisited links. Add an
a:visited:after selector to also match visited links.
Where is the reference for this? <URL:http://www.w3.org/TR/CSS2/generate.html#before-after-content>
<URL:http://www.w3.org/TR/CSS2/generate.html#content>
I agree this would be VERY useful if it consistently worked across
environments.


It's CSS 2, so most likely, IE doesn't support it. Modern browsers
do. After all, CSS 2 has been a recommendation since May 1998.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #16
gb
From: "Lee Mundie" <le**********@ntlworld.com>
Newsgroups: comp.lang.javascript
Sent: Saturday, November 22, 2003 10:22 PM
Subject: Re: Problem printing popup pages.

<a href="javascript:onClick=window.print()">print</a> should work.
Regards
Lee
Lee,

Problem is that it does'ent. This prints the original page not the popup
page. Even though this has been included in the new window using
document.write(). Is this a browser issue?

Giles

"
Jul 20 '05 #17

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

Similar topics

4
by: Jamey Shuemaker | last post by:
I've been looking for a way to do a duplex print job without a duplex printer. I reviewed some old posts about printing odd pages and found that most of them led to KB article 101075 or an export...
0
by: Chang Shiung | last post by:
Hi We have discovered a problem when printing web pages in Internet Explorer 6 (IE6) that have HTML sources like this <TABLE ....><TR><TD><TABLE .... that spans more than one page...
7
by: Amirallia | last post by:
Hello! I have a wecontrol table in a page, this table has a number of variable rows depending of the choice of the user. But when the table has a large number of rows, the printing of the page...
1
by: mark | last post by:
I can't seem to get the logic for printing multiple pages. I know I have to do a comparison between the bottom margin and the position of the next line to be printed and initiate a has more pages...
14
by: abhishekkarnik | last post by:
Hi, I am trying to read an exe file and print it out character by character in hexadecimal format. The file goes something like this in hexadecimal 0x4d 0x5a 0x90 0x00 0x03 .... so on When I...
3
by: bmerlover | last post by:
After hours of trying I got it to print and print preview the richtextbox. I've been trying to figure out how to print multiple pages. If the richtextbox contains more than 1 page of data, than it...
0
by: gnewsgroup | last post by:
In my asp.net 2.0 web application. I create chart images on the fly by getting the data from the database. These chart images all have fixed width, but the height is dynamic depending on the...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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...
0
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,...

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.