PDA

View Full Version : Combining 2 print scripts



egghead2000
04-09-2008, 11:07 PM
1) Script Title: Dynamic Drive- Cross-browser print button and
Alternate document for printing

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex9/other1.htm and
http://www.dynamicdrive.com/dynamicindex9/printstyle.htm

3) Describe problem: Is it possible to use both of the abovr scripts on the same web page?
I want to print a coupon without printing the button. When I try printing, I get the message "Page not found"

www.noahsvideo.com/pelusocoupon.htm

rangana
04-10-2008, 02:00 AM
Yes, both of them can be combined in one page :)


When I try printing, I get the message "Page not found"

It's because you had link it to a page where i'm not even sure that you had uploaded in your server:
http://www.noahsvideo.com/printerversion.doc

Printerversion.doc is the file that you wanted to be printer, but it does'nt even shows up
..as a result..Page cannot be found error is printed ;)

egghead2000
04-10-2008, 02:26 AM
I'm sorry I'm such a dufus, but where do I place, http://www.noahsvideo.com/printerversion.doc

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

egghead2000
04-10-2008, 02:28 AM
Oooops, I mean: Printerversion.doc

rangana
04-10-2008, 02:32 AM
Nop, this has nothing to do with the script :)

...Upload in your server the file printerversion.doc

egghead2000
04-10-2008, 03:56 AM
Ok, here's another dumb question.....I just did a search and I can't find the file printerversion.doc

rangana
04-10-2008, 04:06 AM
Create your own.....a file..either through Adobe Acrobat or MS Word, Excel, PPT of your own.

A file which you wanted to print when the user hit's ctrl + p or when they click the button Print Coupon.

....Read DD (http://www.dynamicdrive.com/dynamicindex9/printstyle.htm)..It will help you understand much better.

You just have to note...that printerversion.doc is a file...it's a MS Word file that will be printed when the user tries to print...hope that makes sense :)

djr33
04-10-2008, 04:24 AM
I do not think you should be using a Microsoft word document. that requires that the visitor 1. have microsoft word and 2. that they open it just to print.
Save an alternate html file; the rest should work similarly.

However, in the end, the best idea with this is not to do something complex with Javascript, but just have a "printable version" link and link to the other page. Then the user can print whichever version they want. That is what most good sites do.

egghead2000
04-10-2008, 04:38 AM
How do I get the print button to print another page. That was my first thought.

egghead2000
04-10-2008, 04:41 AM
Thanks, I tried typing a word document and I tries importing a file from Photoshop anboth just printed a blank page

t
Create your own.....a file..either through Adobe Acrobat or MS Word, Excel, PPT of your own.

A file which you wanted to print when the user hit's ctrl + p or when they click the button Print Coupon.

....Read DD (http://www.dynamicdrive.com/dynamicindex9/printstyle.htm)..It will help you understand much better.

You just have to note...that printerversion.doc is a file...it's a MS Word file that will be printed when the user tries to print...hope that makes sense :)

egghead2000
04-10-2008, 04:46 AM
Ho do I convert the following script to print a different page?

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

egghead2000
04-11-2008, 04:42 AM
Here is some CSS code that works GREAT!!!!! I found it on another site.

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 2</title>

<style type="text/css">
@media print {
.hidebutton {
display:none;
}
}
</style>





</head>

<body>

<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="100%">.</td>
</tr>
<tr>
<td width="100%"><img border="0" src="COUPON-BW-1.gif" width="625" height="425"></td>
</tr>
<tr>
<font color="#FFFFFF">
<td align="center">.</font>
<p>.<input type="Button" name="Capture" value="Print Coupon" onclick="window.print()" class="hidebutton" />


<td width="100%">

</td>
</tr>
</table>
</center>
</div>

</body>

</html>