By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,238 Members | 1,661 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,238 IT Pros & Developers. It's quick & easy.

Printing a target frame

P: n/a
I have a webpage that uses frames (yes I know, frames - previously been
flamed about that, but I do not know anything else to use since I am
clueless!!! Been asked to cobble together a site since there is a
misconception that I know what I am doing!!!)

Anyway, one of the things I have been asked to do is create a button
that will allow the user to print the contents of the main window (main
frame) without the navigation bar (header frame) being printed.

Having been looknig into this, I have found the following

================================================== ==========
Script: Print Page From Different Frame

Functions: This simple script allows you to print the con-
tent of one frame from a link in another frame.

Browsers: All

Author: etLux
================================================== ==========


Put the following script in the <head>...</headsection of
your page. The script belongs in the page where the print
link is located -- *not* in the page to be printed.

Step 1.

// (C) 2004
// Free for all users, but leave in this header
function framePrint(whichFrame){


Step 2.

To create a print link, use the following general form:

<a href="javascript:framePrint('FRAMENAME');">

Change FRAMENAME to the name of the frame (you can find
that in your frameset page code) that you wish to print.

Now I have followed the instrctions as provided I have replaced
FRAMENAME with the name of my frame (main) and I have deleted from
various pages the Base= code that this script seems not to like.

My problem is, when I click my desired button (I have changed the text
link to an image), I get an "access is denied" error. There has only
been one instance when this hasn't happened and that was when I had a
blank html file loaded into the main window and this file was located
in the same directory as all my other html.

Why am I getting an access is denied error? How can I resolve it? Boss
isn't going to be happy if this button doesn't work and he isn't the
type of person to accept that I have no knowledge of how to do this!

If it helps at all, this is the code I am using in my Header frame.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<META http-equiv="Content-Type" content="text/html;
<META name="AUTHOR" content="Simon Argent">
<script language="JavaScript">
function FP_preloadImgs() {//v1.0
var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image;
d.FP_imgs[i].src=a[i]; }


function FP_swapImg() {//v1.0
var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array();
for(n=2; n<args.length;
n+=2) { elm=FP_getObjectByID(args[n]); if(elm) {
elm.$src=elm.src; elm.src=args[n+1]; } }


function FP_getObjectByID(id,o) {//v1.0
var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById)
else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el)
return el;
if( || return o; if(o.childNodes) c=o.childNodes;
for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el)
return el; }
f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el)
return el; } }
return null;

// -->

// (C) 2004
// Free for all users, but leave in this header
function framePrint(whichFrame){


<BODY bgcolor="#5CAEDD" text="#000000" alink="#0000FF" bottommargin="2"
marginwidth="2" marginheight="2"
/*url*/'images/button10.gif', /*url*/'images/button1E.gif',
style="position:absolute;left:1115px;top:47px;widt h:54px;height:37px;z-index:0"
<FONT face="Arial" size="2">&nbsp;</FONT></DIV>
<IMG src="images/px_wbint_cinema4_02.gif" alt="" border="0"
style="position:absolute;left:3;top:8;z-index:1" id="Title" width="567"
<div style="position: absolute; left: 1088px; top: 68px; width: 151px;
height: 30px; z-index: 6" id="Search">
<a href="../Search.html">
<img border="0" id="img2" src="images/button1D.gif" height="30"
width="150" alt="Search" fp-style="fp-btn: Glass Capsule 1;
fp-transparent: 1" fp-title="Search"
<div style="position: absolute; left: 1088px; top: 33px; width: 152px;
height: 31px; z-index: 5" id="Print">
<a href="javascript:framePrint('main');">
<img border="0" id="img1" src="images/buttonE.gif" height="30"
width="150" alt="Print" fp-style="fp-btn: Glass Capsule 1;
fp-transparent: 1" fp-title="Print"
style="position:absolute;left:12px;top:107px;width :54px;height:19px;z-index:2"
<FONT size="2" face="Arial">&nbsp;</FONT></DIV>
style="position:absolute;left:12px;top:145px;width :54px;height:19px;z-index:3"
<div style="position: absolute; left: 15px; top: 72px; width: 413px;
height: 27px; z-index: 4" id="JavaApp">

Much appreciated.

Nov 17 '06 #1
Share this Question
Share on Google+
2 Replies

P: n/a
Well I have managed to HALF fix my problem.

Instead of using the function, I am using the following -

<a href="javascript:parent.focus('main');

(I also have my image files linked in afterwards but that is not a
relevant part of the script).

What is happening now is that my Header frame is being printed and then
on a seperate page my Main frame is being printed.

I also tried

<a href="javascript:parent.focus('main'); parent.print('main');">

but this made no difference.

At least now I am printing (even though it is 2 frames instead of 1).
How can I modify this to only print the single frame?

Thank you.

Nov 17 '06 #2

P: n/a

PieOPah wrote:
<a href="javascript:parent.focus('main');
AFAIK window.print method doesn't take any arguments.

<a href="noscript.html"

with link located in your "menu" frame should work.

Nov 17 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.