Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2006
    Location
    Glorious West Sussex
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macintosh JavaScript print function

    I am relatively new to programming and trying to get a bit of script someone else wrote to work but only part of the script seem to be working and I don't know enough about JavaScript to understand all of the script. Basically what I am trying to do is write a script for a printer friendly page. We have rather elaborate page layouts that do not print very well so I am trying to create a script that only prints out certain elements of a page i.e page title, content, date, url and content heading.

    Please can anyone help?

    This is the code that we link to the web page template

    //This script is used in all templates for the print function
    function openTemplatePrintBox() { /* this function opens up a printer friendly version of the page */

    pWin = window.open("about:blank", "printWindow", "height=530,width=740,location=no,menubar=yes,status=no,toolbar=no,resizable=yes,scrollbars=yes" );
    var t = document.forms.fields.PageTitle.value; //this is the same reference used by feedback - it was forms[1].PageTitle
    var d = pWin.document;
    d.open("text/html");
    d.writeln("<html><head><title>" + t + "</title>")
    d.writeln("<link href=\"/__802569F4005E3A85.nsf/vWeb/flNDRK6QTEE8/$File/PortalStyleSheetv4.css\" rel=\"stylesheet\" type=\"text/css\"></head>\n");
    d.writeln("<body bgcolor=\"white\" text=\"black\" onload=\"javascript:window.print()\">");
    d.writeln(document.all["divPageTitle"].innerHTML);
    d.writeln(document.all["divContentBox"].innerHTML);
    d.writeln("</body></html>\n");
    d.close();

    }

    This is the code on the template page relating to the ubove script. Also I have to CSS divs called "divPageTitle" and "divContentBox".

    <A href="JavascriptpenTemplatePrintBox()">Print</a>
    <form name=fields>
    <input type="hidden" name="DocOwner" value="amanet@baa.com">
    <input type="hidden" name="PageTitle" value=" - ">
    <input type="hidden" name="SiteName" value="AMA-net">
    </form>

  • #2
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    I would be inclined to look into print style sheets: http://www.alistapart.com/stories/goingtoprint/

    It should save you considerable heartache!

    Hope this helps

    m_n
    "Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
    and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
    -Tommy Cooper

  • #3
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    See this Javascript print tutorial.

    http://www.developerzone.biz/index.p...=150&Itemid=45

    Hope this helps
    www.hotdir.bizDirectory ||www.ebooklobby.comFree 5000+ ebooks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •