Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Printing a target frame

Reply
Thread Tools

Printing a target frame

 
 
Simon.Argent@gmail.com
Guest
Posts: n/a
 
      11-17-2006
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
================================================== ==========

INSTRUCTIONS:

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

Step 1.

<script>
// (C) 2004 www.CodeLifter.com
// Free for all users, but leave in this header
function framePrint(whichFrame){
parent[whichFrame].focus();
parent[whichFrame].print();
}
</script>

Step 2.

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

<a href="javascript:framePrint('FRAMENAME');">
CLICK TO PRINT
</a>

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">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<TITLE></TITLE>
<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) {
doc.$imgSwaps[doc.$imgSwaps.length]=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)
el=o.getElementById(id);
else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el)
return el;
if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes;
if(c)
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;
}
// -->
</script>

<script>
// (C) 2004 www.CodeLifter.com
// Free for all users, but leave in this header
function framePrint(whichFrame){
parent[whichFrame].focus();
parent[whichFrame].print();
}
</script>

</HEAD>
<BODY bgcolor="#5CAEDD" text="#000000" alink="#0000FF" bottommargin="2"
marginwidth="2" marginheight="2"
onload="FP_preloadImgs(/*url*/'images/buttonF.gif',
/*url*/'images/button10.gif', /*url*/'images/button1E.gif',
/*url*/'images/button1F.gif')">
<DIV
style="position:absolute;left:1115px;top:47px;widt h:54px;height:37px;z-index:0"
align="left">
<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"
height="67">
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<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"
onmouseover="FP_swapImg(1,0,/*id*/'img2',/*url*/'images/button1E.gif')"
onmouseout="FP_swapImg(0,0,/*id*/'img2',/*url*/'images/button1D.gif')"
onmousedown="FP_swapImg(1,0,/*id*/'img2',/*url*/'images/button1F.gif')"
onmouseup="FP_swapImg(0,0,/*id*/'img2',/*url*/'images/button1E.gif')"></a></div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<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"
onmouseover="FP_swapImg(1,0,/*id*/'img1',/*url*/'images/buttonF.gif')"
onmouseout="FP_swapImg(0,0,/*id*/'img1',/*url*/'images/buttonE.gif')"
onmousedown="FP_swapImg(1,0,/*id*/'img1',/*url*/'images/button10.gif')"
onmouseup="FP_swapImg(0,0,/*id*/'img1',/*url*/'images/buttonF.gif')"></a></div>
<p>&nbsp;</p>
<DIV
style="position:absolute;left:12px;top:107px;width :54px;height:19px;z-index:2"
align="left">
<FONT size="2" face="Arial">&nbsp;</FONT></DIV>
<DIV
style="position:absolute;left:12px;top:145px;width :54px;height:19px;z-index:3"
align="left">
&nbsp;</DIV>
<div style="position: absolute; left: 15px; top: 72px; width: 413px;
height: 27px; z-index: 4" id="JavaApp">


Much appreciated.

 
Reply With Quote
 
 
 
 
Ian Wilson
Guest
Posts: n/a
 
      11-17-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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.
>


<Javascript deleted>

JavaScript (originally Netscape's "LiveScript") is a completely
different language from Java (originally Sun's "Oak"). If I were you I'd
post your question to a JavaScript newsgroup.

Having said that, CSS will do all you want. You can specify which
elements are to be hidden when the media is print rather than screen.
Five or so lines of CSS in the <head> might suffice.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in setting Target Node and Target Tree Property mohit ASP .Net 0 01-23-2008 05:41 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-18-2007 10:11 AM
Printing a target frame PieOPah Javascript 2 11-17-2006 02:43 PM
target form field in iframe w/in frame from other frame starman7@hotmail.com Javascript 2 05-27-2005 10:25 AM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM



Advertisments