Interactive Button for Printing

K

Kerry

Hi,
My question is: How do I setup a button on the bottom of a page that will
print the page. I would also like a "close window button since I'm using
these on a pop-up window.

I found the code:
<!-- Begin
function printWindow() {
bV = parseInt(navigator.appVersion);
if (bV >= 4) window.print();
}
// End -->
</script>

followed by: <a href="javascript:printWindow()">Print This Page</a>

which does work with the words "print this page". However, how do I get
that to work with an interactive button? Is there an easy way to close the
window with a similar button?
 
M

Murray

Actually, that code will fail in IE5/Mac.

Here's what you should use -

Put this in the head of the document -

<script type="text/javascript">
function print_page(where){
var is_mac=(navigator.platform.indexOf("ac") != -1);
(document.all && is_mac)?
alert("Select \"Print\" from the menu") : where? where.window.print() :
window.print();
}
</script>

Put this in the body of the document -

<a href="javascript:print_page()">Print this</a>

And if you want it to be a button, then you can use this -

<button onClick="print_page()">Print Page</button>

You could close the window with -

<button onClick="self.close()">Close</button>
 
K

Kerry

Thanks so much Murray! That works great. Is there a way to assign code to
Frontpage's nice interactive buttons and do the same thing?

Murray said:
Actually, that code will fail in IE5/Mac.

Here's what you should use -

Put this in the head of the document -

<script type="text/javascript">
function print_page(where){
var is_mac=(navigator.platform.indexOf("ac") != -1);
(document.all && is_mac)?
alert("Select \"Print\" from the menu") : where? where.window.print() :
window.print();
}
</script>

Put this in the body of the document -

<a href="javascript:print_page()">Print this</a>

And if you want it to be a button, then you can use this -

<button onClick="print_page()">Print Page</button>

You could close the window with -

<button onClick="self.close()">Close</button>
 
M

Murray

I usually avoid such interactive buttons, preferring to do it manually.

When you insert an interactive button, you would just enter this in the link
field -

javascript:self.close();

Or, you could manually modify the code as follows -

<a href="javascript:self.close()">
<img border="0" id="img2" src="images/button6.jpg" height="20" width="100"
alt="Check this"
onmouseover="FP_swapImg(1,0,/*id*/'img2',/*url*/'images/button7.jpg')"
onmouseout="FP_swapImg(0,0,/*id*/'img2',/*url*/'images/button6.jpg')"
onmousedown="FP_swapImg(1,0,/*id*/'img2',/*url*/'images/button8.jpg')"
onmouseup="FP_swapImg(0,0,/*id*/'img2',/*url*/'images/button7.jpg')"
fp-style="fp-btn: Border Bottom 1" fp-title="Check this"></a>

--
Murray
============

Kerry said:
Thanks so much Murray! That works great. Is there a way to assign code
to
Frontpage's nice interactive buttons and do the same thing?
 
R

Ronx

Create the interactive buttons, and for the hyperlinks use
javascript:print_page()
and
javascript:self.close()

--
Ron Symonds
Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.

Kerry said:
Thanks so much Murray! That works great. Is there a way to assign
code to
Frontpage's nice interactive buttons and do the same thing?
 
M

Mark E.

Ronx and Murray,
I really envy the ease with which you guys seem to know how to do this. Can
you possibly explain how to insert a print function in just a simple manner?
A walkthrough of where I would past what piece of code?

I really have no idea what you guys are talking about.

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top