473,402 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Printing a target frame

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

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

Nov 17 '06 #1
2 5892
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');
javascript:parent.print('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
VK

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

<a href="noscript.html"
onclick="
top.frames['main'].focus();
top.frames['main'].print();">Print</a>

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

Nov 17 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tony Williams | last post by:
i have a frames based website, my java menu is in frame "contents" but i want it to load the page in to frame "main", here is the code i have so far: function init() { menus = new menu(130,...
2
by: RWD | last post by:
I am trying to figure out how to change the target frame in my hyperlink on a DHTML menu. The menu is in one frame and the target frame is called "main" The code is below: Thanks in advance...
5
by: J | last post by:
Hi, I'm using the following code snippet to show popup menus (in a header frame) and target the menu options to another frame. This works fine for a single hard-coded frame (e.g. "2" below, in...
1
by: Richard Brand | last post by:
We run into a strange problem with a client when printing a frame from a website. On the site there is a button that performs the following javascript code: parent.myFrame.focus();...
4
by: DaveO | last post by:
Hi all I have done lots of VB programming, but am not familiar with JavaScript. Can anyone tell me how to do this ....? I have a JS file for a menu system called menu.js It contains the...
0
by: jvc214 | last post by:
I have an application that uses multiple frames. Normally the links in a frame target the frame they are in, except when "something special" occurs on the server side for the request. When that...
1
by: Steve Harrison | last post by:
I have a simple ASP page with two buttons. When the first button is pressed I want to update a label on the same page, but when the other button is pressed I want to display a new page, and show it...
0
by: SAL | last post by:
Hello, I'm working with, C#, Framework 1.1, and Visual Studio 2003. I built a Webform that uses Frameset which has 4 frames (Header, Footer, Main, and Contents) and I set the NavigationUrl...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.