May 16, 2008

Button To Print Current Web Page

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > HTML, XML etc..
Pages: 1, 2

free web hosting

Button To Print Current Web Page

fsoftball
Hi,

Does anyone know how to create a button that will printo out the current page.

What I want to do is have the user fill out a form (containing name, address, zip, etc). They will then click on a "print" button and it will print out the form data. Any ideas?

Thanks.

Reply

cragllo
If you know php, then you could make it so that the form data is 'sent' and displayed on a new page, then have print butten (that may be done with javascript, dunno how tho)

If you need some help, just ask...

Reply

fsoftball
Thanks for the help. I can do the PHP part, I get that. It's the sending it to the printer that I would like to know how to do.

Reply

cragllo
A quick search, and I found this:

CODE
<script Language="Javascript">

/*
This script is written by Eric (Webcrawl@usa.net)
For full source code, installation instructions,
100's more DHTML scripts, and Terms Of
Use, visit dynamicdrive.com
*/

function printit(){  
if (window.print) {
   window.print();  
} else {
   var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
   WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
}
}
</script>

<script Language="Javascript">  
var NS = (navigator.appName == "Netscape");
var VERSION = parseInt(navigator.appVersion);
if (VERSION > 3) {
   document.write('<form><input type=button value="Print this Page" name="Print" onClick="printit()"></form>');        
}
</script>


All tyhe information you need is here, also gives a demo too: http://dynamicdrive.com/dynamicindex9/other1.htm

 

 

 


Reply

Inspiron
cragllo has given a slightly complicated code...
It is broswer sensitive as it test your broswer compatibility before executing the codes...

Here's my version, simple and easy to understand...
This code loads faster as well...

CODE

<html>

<head>
<title>New Page 1</title>
<script language="javascript">
function printpage()
 {
  window.print();
 }
</script>
</head>

<body>

<form>
<input type="button" value="Print" onclick="printpage();">
</form>
</body>

</html>

Reply

cragllo
That is simple tongue.gif
And all this talk about printing a page has given me an idea, i will add an options bar to my site smile.gif

You can also use this code instead of the form:
CODE
<a href="" onclick="printpage();">print</a>

Reply

Mike
Interesting... All this stuff makes my head explode! dry.gif Anyways, I like the window.print() function the best with JavaScript because it's so simple and you basically cannot forget it. But are you sure that you add the semi-colon (wink.gif at the end of a function in JavaScript?

Reply

spacemonkey
You could even omit the Javascript with the function by using the command right from the button:
CODE
<input type="button" value="Print Page!" onclick="window.print()" />

Reply

monkeys-r-orange
Thank you for helping so many of us.

I have always woundered how to allow users to print a page of my website.

thanks again.

happy.gif

Reply

Trap FeedBacker
how to print without asking the dialogue box.
Button To Print Current Web Page

I am using the window.Print(); option for printing the current page .

Here it is asking me which printer to print ect...

In a dialogue box.
I want to select the default printer of that machine and print it automatically.

-question by honey

Reply

Latest Entries

tefanclub
thanks rolleyes.gif

Reply

galexcd
Of course you couldn't print without displaying the box first. If javascript had that kind of power could you imagine the abuse websites could do? Print out 40 pages of pure black while your surfing the net and you wouldn't even know until you hear the printer going.

QUOTE(delivi @ Feb 6 2008, 08:36 AM) *
This will work in IE, FF & Opera but not in safari


It works fine in safari.

Reply

delivi
I a simple link with this code is enought to print the content of the page

CODE
<a href="java script:print();">Print this Page</a>


This will work in IE, FF & Opera but not in safari

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Pages: 1, 2
Recent Queries:-
  1. php print page - 1.06 hr back.
  2. code to print document on web pages on click of button - 5.91 hr back.
  3. php print webpage - 7.04 hr back.
  4. add print button to html form - 10.43 hr back.
  5. print this page php - 12.56 hr back.
  6. print button webpage - 12.65 hr back.
  7. buttons printen - 15.42 hr back.
Similar Topics

Keywords : button, print, current, web, page

  1. Multiple Drop Down Menus W/ Submit Button
    (6)
  2. Dynamic Button Size
    (1)
    In my application I have a custom tag that generates all the action buttons that the page needs. My
    problem is that in IE the space between the left side of the button and the image inside the button
    are not consistant. Some buttons have 3 or 4 more pixels of padding on the left side then others.
    This causes my buttons to be too large and hence the area the buttons are generated in stretches too
    far. I could wrap the buttons around to another line or add scroll bars.. but if it will fit in FF I
    think it should fit in IE as well. So my question is can I set the padding....
  3. Refresh Page After Back Button Hit
    (5)
    Hi. I have a page that is dynamically build through DOM manipulation. So, when I browse outside the
    page, and then click back, those dynamically created DOM objects are gone. Since I am also using JSP
    / Servlet technology, I can rebuild this page easily, which I have done. Here is my dilemma. If
    the user leaves the dynamic page, then clicks back on their browser, I need the page they are going
    back to to refresh. I can't figure out how to do this. I've tried using the META tag, but it
    won't do it. Help would be appreciated. Thanks. ....
  4. Submit Button
    (3)
    I have a form on my page. I do not have a submit button, but when I hit enter on my text field, it
    is like I am clicking on a submit button. My page refreshes to the original state, and my values are
    reset. I found this out because I made a submit button and tried it. Is there a way to get around
    this? I am trying to use a javascript that captures the key strokes. That works, but then the submit
    like event still fires after my code runs, nullifying any changes my code has made. html4strict
    Code: CODE 1.      <form name="FormPictureInfo">   2.....
  5. Radio Button
    (3)
    I am trying to maintain the radio button selection on a Submit, but the form refreshes to its
    default selection. BTW, After a Submit is clicked, the radio form stays visible on the top of the
    screen while the query results are displayed on the bottom half of the screen (we're using an
    internal, embedded link). That's when the default selection comes into place. Any help would be
    appreciated. Please respond Kvarnerexpress.....
  6. Substitute Form Button For An Image
    homemade images in forms buttons (3)
    Hi, I have the next formular : CODE  <form method='post'
    action='index.php?mode=2&id=1'>                <input type='hidden'
    name='name' value='Canon Digital Ixus 700'/>                <input
    type='hidden' name='id' value='1'/>                <input
    type='hidden' name='qty' value='1'>                <input
    type='hidden' name='cost' value='40'>                <input
    type='submit' value='Add to ca....
  7. Enter Keypress Submits Wrong Button
    (2)
    Ive got a form, with a submit button on the left and a submit button on the right. By default on the
    enter keypress, the form submits the left submit button, but i want it to submit the right button.
    How would i accomplish this? kvarnerexpress....

    1. Looking for button, print, current, web, page

Searching Video's for button, print, current, web, page
advertisement



Button To Print Current Web Page



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE