Nathan Sokalski wrote on 02 jan 2010 in
microsoft.public.scripting.jscript:
> I'm not sure if you can do it from the same page, but try doing
> something like this:
> Use an anchor with target="_blank" as follows:
> <a href="firstpagetoprint.aspx" target="_blank">Print</a>
> In firstpagetoprint.aspx, include the following in the onload event of
> the body tag:
> window.print();window.location.replace("secondpagetoprint.aspx");
> Include this code in the onload event of the body tag for
> thirdpagetoprint.aspx, fourthpagetoprint.aspx, fifthpagetoprint.aspx,
> etc. Then, in the onload event of the body tag for
> lastpagetoprint.aspx, use the following:
> window.print();window.close();
> Doing this will basically open a new page in a new window, print it,
> move to the next page, print it, and after printing the last page,
> close the new window. Unfortunately, because this requires you to have
> a different URL for each section you want to print, you may need or
> want to make an aspx page that takes a query string to generate the
> content you want printed for that specific section. Hopefully this
> helps!
Serverside code could supply different results with the same url,
using a counter stored in a session variable.
However you could get clientside cashing problems.
Classic ASP example:
<a href="pagenumbertoprint.asp?1" target="_blank">Print</a>
window.print();window.location.replace("pagenumbertoprint.asp?2");
window.print();window.location.replace("pagenumbertoprint.asp?3");
etc
will do nicely using serverside:
<% ' Jscript
var n = Request.querystring;
if (n=1) {
%>
-- first page ---
<%
} else if (n=2) {
%>
-- second page ---
<%
} else if (n=3) {
// etc etc
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)