473,587 Members | 2,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(whic hFrame){
parent[whichFrame].focus();
parent[whichFrame].print();
}

</script>

Step 2.

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

<a href="javascrip t:framePrint('F RAMENAME');">
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="JavaS cript">
<!--
function FP_preloadImgs( ) {//v1.0
var d=document,a=ar guments; 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,ar gs=arguments,el m,n; doc.$imgSwaps=n ew Array();
for(n=2; n<args.length;
n+=2) { elm=FP_getObjec tByID(args[n]); if(elm) {
doc.$imgSwaps[doc.$imgSwaps.l ength]=elm;
elm.$src=elm.sr c; elm.src=args[n+1]; } }

}

function FP_getObjectByI D(id,o) {//v1.0
var c,el,els,f,m,n; if(!o)o=documen t; if(o.getElement ById)
el=o.getElement ById(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_getObject ByID(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_getObject ByID(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(whic hFrame){
parent[whichFrame].focus();
parent[whichFrame].print();
}

</script>

</HEAD>
<BODY bgcolor="#5CAED D" text="#000000" alink="#0000FF" bottommargin="2 "
marginwidth="2" marginheight="2 "
onload="FP_prel oadImgs(/*url*/'images/buttonF.gif',
/*url*/'images/button10.gif', /*url*/'images/button1E.gif',
/*url*/'images/button1F.gif')" >
<DIV
style="position :absolute;left: 1115px;top:47px ;width:54px;hei ght:37px;z-index:0"
align="left">
<FONT face="Arial" size="2">&nbsp; </FONT></DIV>
<IMG src="images/px_wbint_cinema 4_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_s wapImg(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="javascrip t:framePrint('m ain');">
<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_s wapImg(0,0,/*id*/'img1',/*url*/'images/buttonF.gif')"> </a></div>
<p>&nbsp;</p>
<DIV
style="position :absolute;left: 12px;top:107px; width:54px;heig ht:19px;z-index:2"
align="left">
<FONT size="2" face="Arial">&n bsp;</FONT></DIV>
<DIV
style="position :absolute;left: 12px;top:145px; width:54px;heig ht: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 5919
Well I have managed to HALF fix my problem.

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

<a href="javascrip t:parent.focus( 'main');
javascript:pare nt.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="javascrip t:parent.focus( 'main'); parent.print('m ain');">

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="javascrip t:parent.focus( 'main');
javascript:pare nt.print('main' );">
AFAIK window.print method doesn't take any arguments.

<a href="noscript. html"
onclick="
top.frames['main'].focus();
top.frames['main'].print();">Prin t</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
4126
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, "vertical", 10, 10, -2, -2, "#CACAFF", "#0000A0", "Verdana,Helvetica", 9, "bold", "bold", "black", "white", 1, "gray", 2, "rollover:tri.gif:tri.gif", false, true, true, true, 12, true, 4,
2
5287
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 RWD <script type='text/javascript'>
5
1496
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 doClick) but I need to pass in the target frame ID when the user clicks, the reason being that different options will target different frames depending on who the user is. the target frame name is in the target attribute of the link tag, i.e. <a...
1
1804
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(); window.print(); This is the normal way to print a specific frame from a website. Our client works on a SBS2003 with Terminal Server and when they hit the button all frames are printed out, not just the selected one. At first I thought that
4
13844
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 following function :
0
1476
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 special something happens, I need to target _top or top (the top level browser window). I have two approaches and I am open to others: 1. I respond to the request with javascript that has: top.location.href = /where/I/really/want/the/top/to/go ...
1
1468
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 in a different frame. I can't find a way of setting the target frame dynamically - any ideas? Thanks, Steve
0
1410
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 property for each frame to the .aspx I want shown in each frame. I'm using the Contents frame as a menu that contains Hyperlinks to the page I want displayed. However, if I don't set the Target property for my Hyperlink control, then when it is...
0
7854
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8219
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8349
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7978
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8221
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6629
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.