SiteBuilder Logo Header


0
Users Online
0 Visitors Today
118 Pages Viewed Today
 

Try J-Bots Plus 2000 or J-Bots 2000 add-in components for FrontPage 2000 featuring components that can make your web sites more attractive, more engaging, and easier to navigate. They're fast and easy to use, and require no programming skills. Simply fill in dialog boxes, click the Generate button, and JavaScript code will automatically create the function you desire.


Microsoft FrontPage

Active Server Pages

Dynamic HTML

Sample Scripts

Web Servers

Tutorials

Third Party Solutions

Links to Other Sites

Discussion Groups

Search


Microsoft Certified Professional

Microsoft MVP

 

 

 

 

*

Sample Scripts

Q. How can I make a button to print a page?

A. There are several ways to do this.

NEW - Here is a new cross-browser script that should work in both Internet Explorer and Netscape.

  1. Switch to HTML View.
  2. In the <head> section of your code, put:

<SCRIPT Language="Javascript"> 
function printthis(){ 
if (NS) {
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>

  1. In the <body> section of your code put:

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


Below is the old individual code for Internet Explorer and Netscape which you can still use (or combine to use) on your page


Here is the code for Internet Explorer:

  1. Switch to HTML View.
  2. In the <head> section of your code, put:

<script language="javascript">
function printo()
{
var OLECMDID_PRINT = 6;
var OLECMDEXECOPT_DONTPROMPTUSER = 2;
var OLECMDEXECOPT_PROMPTUSER = 1;
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
oldHandler = window.onerror;
window.onerror = deal;
WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER);
WebBrowser1.outerHTML = "";
window.onerror = oldHandler;

function deal()
{
WebBrowser1.outerHTML = "";
window.onerror = oldHandler;
return true;
  }
}
</script>

  1. In the <body> section of your code put:

<form>
<input TYPE="Button" VALUE="Print" ONCLICK="printo()">
</form>

Here is the code for Netscape:

  1. Switch to HTML View.
  2. In the <head> section of your code, put:

<script>
<!--
/*
Custom Print Button Script-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, installation instructions,
100's more DHTML scripts, and Terms Of
Use, visit dynamicdrive.com
*/

function doit(){
if (!window.print){
alert("You need NS4.x to use this print button!")
return
}
window.print()
}
//-->
</script>

  1. In the <body> section of your code put:

<form>
<input type="button" value="Print Page" onClick="doit()">
</form>

Note: Both of the above scripts will only work in version 4 browsers.


© Copyright, 1998 - 2003, NetSites, LLC.  All rights reserved.
Email Questions or Comments to sitebuilder@net-sites.com

All products and company names mentioned herein are the trademarks of their respective owners.
Microsoft® and FrontPage® are registered trademarks of Microsoft Corporation in the United States and/or other countries.