Nov 21, 2009
Pages: 1, 2

Button To Print Current Web Page

free web hosting

Read Latest Entries..: (Post #18) by iGuest on Aug 3 2009, 08:07 AM.
HOW TO PRINT DIRECTLY Button To Print Current Web Page I need to print the ticket of size 3" x 8". By simply pressing the button Print. Without even displaying any dialog box. If someone can help that's going to help me. Thanks in adv -question by ANAND
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Open Discussion > MODERATED AREA > Computers > Programming Languages > HTML, XML etc..

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.

Comment/Reply (w/o sign-up)

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...

Comment/Reply (w/o sign-up)

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.

Comment/Reply (w/o sign-up)

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

 

 

 


Comment/Reply (w/o sign-up)

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>

Comment/Reply (w/o sign-up)

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>

Comment/Reply (w/o sign-up)

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?

Comment/Reply (w/o sign-up)

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()" />

Comment/Reply (w/o sign-up)

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

Comment/Reply (w/o sign-up)

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

Comment/Reply (w/o sign-up)

Latest Entries

iGuest
HOW TO PRINT DIRECTLY
Button To Print Current Web Page

I need to print the ticket of size 3" x 8". By simply pressing the button Print. Without even displaying any dialog box. If someone can help that's going to help me. Thanks in adv -question by ANAND

Comment/Reply (w/o sign-up)

iGuest
The print window function
Button To Print Current Web Page

hey all,

 So I have been experimenting with the comman <input type="button" value="Print This Page" onclick="window.Print()">

 The website is for my company, it has 2 java graphs and a java spread sheet. (the spread sheet is just a rectangle with lines and numbers filled in)

 On my mac, safari prints most of it but not the last half of my spreadsheet.

I get 2 pages with everything on it but the third page is blank safe for the         "copyright my_company's_name 2009" at the end.

 I have tried loading this on a linux machine at my school and it does not print the Java at all, I get the form buttons and logos and such but no java.

 I have noticed some slight differences between my code and the code seen here so I will also mention that this is a Perl file printing out CGI HTML, and linking to Java classes.

 Any ideas?

Thanks!

- Tristan


Comment/Reply (w/o sign-up)

iGuest
print mutliple pages
Button To Print Current Web Page

Hello,
I need to print multiple pages( I.E all the pages in websites). Currently I have 10 html pages in my website. If I click print all the ten pages should print one by one. I used java script to print those pages but it print only one pages " window.Print() " function is used.Try to help me to print all my ten pages at a time.

-question by Aswath

Comment/Reply (w/o sign-up)

iGuest
print mutliple pages
Button To Print Current Web Page

Hello,
I need to print multiple pages( I.E all the pages in websites). Currently I have 10 html pages in my website. If I click print all the ten pages should print one by one. I used java script to print those pages but it print only one pages " window.Print() " function is used.Try to help me to print all my ten pages at a time.

Comment/Reply (w/o sign-up)

iGuest
HTML code to print web page
Button To Print Current Web Page

Replying to spacemonkey

Dear Spacemonkey,

Back in May of 2005, you responded to a question of what HTML code is necessary to print a web page that included "fill in form" features. I was impressed with how simple your coding was. You suggested: <input type="button" value="Print Page!" onclick="window.Print()" />

It works like a charm. I have another question for you now. Is there a simple code that sends the selected web page to someone when they click a "Submit" button. I need to know how to include an email address with that feature.

Thanks in advance for any help you can offer.
Tom T

-question by Tom T

Comment/Reply (w/o sign-up)



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*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)

Pages: 1, 2
Similar Topics

Keywords : button, print, current, web, page

  1. Multiple Drop Down Menus W/ Submit Button
    (9)
  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
    (14)
    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.         2.             3.                 4.   ....
  5. Radio Button
    (5)
    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                                                  
                                                  I want to substitue the add button for an
    image CODE that i created but i want still to have the same funcitonlity when someone
    clicks. How can i do this? Thanks in advanced!....
  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
See Also,
advertisement


Button To Print Current Web Page

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com