Cragly
asked on
Master pages and Java Script problem
Hi all,
I have a page that inherits from a master page and what i would like it ot do is that when the page loads i would like the print dialouge to open so that the page can be printed.
The page can not be taken out of a master page and the client is lazy and does not want to just press the print button on the browser. Therefore they require the dialouge to pop up so they can print from that.
any help would be much appreciated.
Many thanks
Cragly
I have a page that inherits from a master page and what i would like it ot do is that when the page loads i would like the print dialouge to open so that the page can be printed.
The page can not be taken out of a master page and the client is lazy and does not want to just press the print button on the browser. Therefore they require the dialouge to pop up so they can print from that.
any help would be much appreciated.
Many thanks
Cragly
ASKER
Hi b0lsc0tt,
Thanks for the reply but the page I need to print inherits from a master page so does not have have a body tag of its own. The body tag resides in the master page and I do not want to put this peice of code in the master page as all pages within the site that use the master page will print.
Cheers
Cragly
Thanks for the reply but the page I need to print inherits from a master page so does not have have a body tag of its own. The body tag resides in the master page and I do not want to put this peice of code in the master page as all pages within the site that use the master page will print.
Cheers
Cragly
One other way to do it is with something like ...
window.onload = function () { window.print(); }
However if by master page, etc you mean you use frames or something like it then this probably won't work either. The frame/pages may not be all loaded. In that case the last thing to try is a timeout.
var t = setTimeOut("window.print() ", 1000);
The second argument is the time in milliseconds so the line above will wait 1 second. Adjust as needed for your site and pages.
Let me know if you have a question or how it works.
bol
window.onload = function () { window.print(); }
However if by master page, etc you mean you use frames or something like it then this probably won't work either. The frame/pages may not be all loaded. In that case the last thing to try is a timeout.
var t = setTimeOut("window.print()
The second argument is the time in milliseconds so the line above will wait 1 second. Adjust as needed for your site and pages.
Let me know if you have a question or how it works.
bol
You can put the following code at the HTML code of the page(not the master one):
<script language="javascript">wind ow.print() ;</script>
<script language="javascript">wind
ASKER
Hi guys,
Thanks for your posts but neither of these work within an asp.net 2.0 environment using master pages.
Cheers
Cragly
Thanks for your posts but neither of these work within an asp.net 2.0 environment using master pages.
Cheers
Cragly
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yes , all sorted and keeping the solution and having the points refunded would be great thanks.
Cheers
Cragly
Cheers
Cragly
In the page's body tag make the following change ...
<body onload="window.print();">
Let me know if you have any questions or need more information.
b0lsc0tt