[Seaside] Print only a particular div

Rajeev Lochan lochan94 at gmail.com
Wed Jan 2 19:02:21 UTC 2008


For the above code, I am getting the following error in fireBug

*print_win is not defined*


Any idea, where I am wrong.

Regards,
Rajeev


On Jan 3, 2008 12:16 AM, Rajeev Lochan <lochan94 at gmail.com> wrote:

> Thanks Philippe for correcting me.
> After some modifications the Js code is
>
>
> printwindowJs
>     ^ '
> function chkstate(){
> if(document.readyState=="complete"){window.close()}
> else{setTimeout("chkstate()",2000)}}
>
> function print_win(){
> window.print();chkstate();}
>
>
>     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(''</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()
> }
>
> '
>
>
> Now, I am getting a popup browser with the div rendered in it. But the
> automatic printerSelection menu is not coming. I hope I am closer than last
> time.
>
> Regards,
> Rajeev
>
>
> On Jan 2, 2008 11:47 PM, Philippe Marschall <philippe.marschall at gmail.com>
> wrote:
>
> > 2008/1/2, Rajeev Lochan <lochan94 at gmail.com>:
> > > 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>'
> >
> > Why do you put <script>-Tags in JavaScript code?
> >
> > Cheers
> > Philippe
> >
> > > 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
> > > _______________________________________________
> > > seaside mailing list
> > > seaside at lists.squeakfoundation.org
> > > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> > >
> > >
> > _______________________________________________
> > seaside mailing list
> > seaside at lists.squeakfoundation.org
> > http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> >
>
>
>
> --
>
> 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/20080103/40314e39/attachment-0001.htm


More information about the seaside mailing list