2022.2

Table Of Contents
UsingJavaScriptfilesinatemplate
Including a JavaScript file in a Web context
TolinkaJavaScriptfiletotheWebcontext,ortoacertainWebsectionorCOTGtemplate:
1. OntheResourcespane,expandtheContextsfolder,andtheneitherright-clicktheWebcon-
text,orexpandtheWebcontextandright-clickaWebsection.
2. ClickIncludes.
3. FromtheFile typesdropdown,selectJavaScripts.
4. TheavailableJavaScriptfilesarelistedattheleft.Usethearrowbuttonsordouble-clicktomove
theJavaScriptfilesthatshouldbeincludedtotheright-handlist.UsingtheUpandDownbuttons
ordrag-and-dropyoucanchangetheorderofthefiles,too.
5. ClickOK.
Note: JavaScriptfilesthatarelinkedto(i.e.includedin)asectionshowachainiconinthe
Resourcespane(see"Resourcespane"onpage978).
Note: AnyJavaScriptfilesincludedinasectionrunafterthescriptsintheScriptspane.
Using JavaScript in other contexts
EmailclientsdonotsupportJavaScript.Therefore,EmailcontextscannotincludeJavaScript
resources.
WhenaJavaScriptfileisincludedinaPrintsection,theDesigneritselfactsasthebrowser.Whengen-
eratingPrintoutput,itrunstheJavaScriptaftergeneratingthemainpageflowcontentsandthepagin-
ation,butbeforeanyMasterPagesareadded.SoitispossibletochangePrintoutput(exceptcontent
onMasterPages)byaJavaScript;forexample,toaddabarcodethatincludesthepagenumberto
eachdocument.Awarningisappropriate,however:changingthePrintoutputmaychangethepage
flowanddoingsoatthispointmayresultinbadoutputand/orseriouserrorsoracrashofthesoftware.
Previewing a template with JavaScript resources
WhenasectionispreviewedintheDesigner,scriptsintheResourcespaneareinterpretedbyan
internalbrowser.
JavaScriptresourcesincludedinaWebsectionareonlyexecutedontheLivetab,notonthePreview
tab.
RememberthatthefinaloutputofaWebsectioniseventuallyprocessedbyaclientbrowser.Sinceyou
cannotpredictwhattypeofbrowserwillbeused,youshouldmakesureyourscriptsarecompatible
withawiderangeofbrowsertypesandversions.
Page 515