| |
|
Welcome to KnowledgeSutra - Dear Guest | |
Button To Print Current Web Page
Started by fsoftball, May 11 2005 02:56 PM
22 replies to this topic
#1
Posted 11 May 2005 - 02:56 PM
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.
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.
#4
Posted 11 May 2005 - 04:22 PM
A quick search, and I found this:
All tyhe information you need is here, also gives a demo too: http://dynamicdrive....dex9/other1.htm
<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....dex9/other1.htm
#5
Posted 16 May 2005 - 03:25 PM
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...
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...
<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>
#7
Posted 19 May 2005 - 07:57 PM
Interesting... All this stuff makes my head explode!
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 (
at the end of a function in JavaScript?
#10
Posted 06 February 2008 - 05:46 AM
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
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 to this topic

1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users














