/    Sign up×
Community /Pin to ProfileBookmark

Printing numerous pages through javascript

Ive been using the simple window.print() javascript function which is working fine provided I visit the window inwhich i am wanting to print. Now at the maximum there is three pages which I need to print so Im wondering is there a way of printing all these pages without opening them.

Say I am on webpage A and I want to print webpages B,c and D. Is there a way I can click print all pages and these pages are printed. Any help or clues would be most welcome!! regards Mike

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@felgallJun 12.2007 — The only command that JavaScript has that relates to printing is window.print(). Anything else you want to do with printing has to be done by a program installed on that computer and can't be done from a web page.
Copy linkTweet thisAlerts:
@slaughtersJun 12.2007 — You can print numerous pages via JavaScript if all the pages are in your domain. Useful for printing a lot of your own web pages. Not so useful for printing pages which belong to to others.

The basic steps are:

Write a page that uses javascript to assign a page to the src of an iframe.

Print the iframe.

Load next page.

Continue till done.

very very quick example:[code=html]<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Load and Print</title>
<script>
var i = 0;
var PrintPages=["page1.html","page2.html","page3.html"]

function PrintFrames() {

// Load new URL into iframe if we have not gone through all yet.
if (i < PrintPages.length ) {
print_frameObj = document.getElementById("print_frame");
print_frameObj.src = PrintPages[i];
print_frame.print();
i++;
}

}
</script>
</head>

<body>
<iframe id="print_frame" name="print_frame" Onload="PrintFrames();"></iframe>
</body>
</html>[/code]
×

Success!

Help @cs3mw spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...