[Seaside] Re: Print only a particular div

Rajeev Lochan lochan94 at gmail.com
Wed Jan 2 17:26:48 UTC 2008


>MyRoot>>updateRoot: anHtmlRoot
>   super updateRoot: anHtmlRoot.
>   anHtmlRoot javascript  url: '/seaside/files/ToDoLibrary/printwindow.js'


Theres a typo in the above code, it is MyLibrary instead of ToDoLibrary





On Jan 2, 2008 10:37 PM, Rajeev Lochan <lochan94 at gmail.com> wrote:

> Hi,
> One of the hurdles I am facing is printing only a part of the page/ a
> particular html div. By googling, I tried to do the following steps, but
> still not able to succeed.
>
> I followed instruction given in
> http://www.huntingground.freeserve.co.uk/main/mainfram.htm?../scripts/printing.htm
>
> *1) created a Javascript printWindow.js   with the Js code mentioned
> there.*
>
> MyLibrary>>printwindowJs
>     ^ '<script type="text/javascript">
> <!--
> function printContent(id){
> str=document.getElementById(id).innerHTML
> newwin=window.open
> ('''',''printwin'',''left=100,top=100,width=400,height=400'')
> newwin.document.write(''<HTML>\n<HEAD>\n'')
> newwin.document.write(''<TITLE>Print Page</TITLE>\n'')
> newwin.document.write(''<script>\n'')
> newwin.document.write(''function chkstate(){\n'')
> newwin.document.write(''if(document.readyState=="complete"){\n'')
> newwin.document.write(''window.close()\n'')
> newwin.document.write(''}\n'')
> newwin.document.write(''else{\n'')
> newwin.document.write(''setTimeout("chkstate()",2000)\n'')
> newwin.document.write(''}\n'')
> newwin.document.write(''}\n'')
> newwin.document.write(''function print_win(){\n'')
> newwin.document.write(''window.print();\n'')
> newwin.document.write(''chkstate();\n'')
> newwin.document.write(''}\n'')
> newwin.document.write(''<\/script>\n'')
> newwin.document.write(''</HEAD>\n'')
> newwin.document.write(''<BODY onload="print_win()">\n'')
> newwin.document.write(str)
> newwin.document.write(''</BODY>\n'')
> newwin.document.write(''</HTML>\n'')
> newwin.document.close()
> }
> //-->
> </script>'
>
>
> *2) Added the above Js in #updateRoot: of my rootComponent*
>
> MyRoot>>updateRoot: anHtmlRoot
>     super updateRoot: anHtmlRoot.
>     anHtmlRoot javascript  url:
> '/seaside/files/ToDoLibrary/printwindow.js'
>
>
> *3) MyRoot>>renderContentOn: html*
>
> html div id: 'div1'; with: [ ........... ].
> html div id: 'div2'; with: [ ........... ].
> html div id: 'div3'; with: [ ........... ].
> html div id: 'div4'; with: [ html text: 'Print this Div'.
>                                  html space.
>                                  html html: '<a href="#null"
> onclick="printContent( ' 'div4' ' );">Click to print div 4</a>'.
>
>     html anchor url: '#'; onClick: 'printContent( ' 'printListView' ' )';
>                                       with: 'Print div 4 ' .
>
> I have used both raw html code and modified Seaside/squeak code (I hope
> its equivalent). When I click on any of the anchors, nothing happens. I get
> the following error in Firebug(firefox)
>
> *printContent is not defined*
> *onclick (click clientX=0, clientY=0)*
>
>
> I crosschecked the inclusion of printwindow.js and it is indeed included
> in the Firebug Js browser.
>
> I hope you people can help me where I am committing a dumb mistake(maybe)
> or is there a better way to print only a div.
>
> Thanks & Regards,
> Rajeev
>
>
>
> --
> Rajeev Lochan
>
> Co-founder, AR-CAD.com
>
> http://www.ar-cad.com
> +91 9243468076 (Bangalore)
> 080 65355873




-- 
Rajeev Lochan

Co-founder, AR-CAD.com

http://www.ar-cad.com
+91 9243468076 (Bangalore)
080 65355873
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20080102/69dbe25e/attachment.htm


More information about the seaside mailing list