[pmwiki-users] javascript question, or how to conditionally include javascript:window.print();

Bart pmwiki-users at mediamatrix.nl
Sat Aug 26 06:09:41 CDT 2006


I was thinking of extending the "print" action with, javascript:window.print();
This has the advantage that when someone clicks the "print" link in the
action menu, beside that the layout is adapted to print friendly the printer menu
pops up (if the browser has java enabled)

I like to integrate this in a save and generic way e.g in in the config.php
or pmwiki.tmpl 

For printing I use the default skin without sidebar, which save a lot of
maintenance hassle when chancing skin.
So in my config.php I have included 

##   Get ?action=print to use default 'pmwiki' skin
$ActionSkin['print'] = 'pmwiki';
##   Disable sidebar for ?action=print
if ($action == 'print') { SetTmplDisplay('PageLeftFmt', 0); }

But this way I don't use a separate skin for printing, to unconditional
include a peace of unconditional java script, something like.

<script language="javascript" type="text/javascript">

What I am looking for is a way to include java script conditionally, e.g by
including some smart code in pmwiki.tmpl and or config.php so that the
javascript code is included on any page when action=print 

Is there a way that this can be done? 

For security I don't like to allow java script in a wikipage e.g. my

Thanks, Bart 
The Netherlands

More information about the pmwiki-users mailing list