Printing a target frame

Discussion in 'Java' started by Simon.Argent@gmail.com, Nov 17, 2006.

  1. Guest

    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=new Image;
    d.FP_imgs.src=a; }
    }

    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;width: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, 2006
    #1
    1. Advertising

  2. Ian Wilson Guest

    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.
     
    Ian Wilson, Nov 17, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KathyB
    Replies:
    2
    Views:
    549
    Kathy Burke
    Jul 2, 2003
  2. Steve Harrison

    Dynamically setting the target frame

    Steve Harrison, May 14, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    429
    Yunus Emre ALPĂ–ZEN [MCAD.NET]
    May 14, 2005
  3. mohit
    Replies:
    0
    Views:
    580
    mohit
    Jan 23, 2008
  4. Replies:
    2
    Views:
    202
  5. PieOPah

    Printing a target frame

    PieOPah, Nov 17, 2006, in forum: Javascript
    Replies:
    2
    Views:
    110
Loading...

Share This Page