Page 1 of 1

Including javascript in webhelp topic head

Posted: Tue Aug 06, 2013 8:53 pm
by kmank
I have a need to include some javascript code within the <head> of each topic, and simply need to know (at this point) where to start to make sure the transformation includes my code.

Can someone please provide the file that would need to be modified?

Re: Including javascript in webhelp topic head

Posted: Wed Aug 07, 2013 12:24 pm
by sorin_ristache
Hi,

In what type of transformation would you like to include the JavaScript code in the <head> element: DITA Webhelp, DocBook Webhelp? You posted the question on the XML - General XML Questions forum. Should I move this topic to the Frameworks - Document Types - DITA forum?

You can add custom JavaScript code in the <head> element of the DITA Webhelp transformation by editing the file [Oxygen-15-install-dir]\frameworks\dita\DITA-OT\plugins\com.oxygenxml.webhelp\xsl\createMainFiles.xsl, starting with line 246, before the </head> tag. Just make sure you add a well-formed XHTML fragment that includes your custom code.


Regards,
Sorin

Re: Including javascript in webhelp topic head

Posted: Wed Aug 07, 2013 3:21 pm
by kmank
Thanks for the reply, Sorin. And yes... I did intend for this to be in Frameworks - Document Types - DITA

Sorry I was not descript enough - I was meaning DITA Webhelp, so you've answered the question. Thanks much!! :)

Re: Including javascript in webhelp topic head

Posted: Wed Aug 07, 2013 3:38 pm
by sorin_ristache
OK, I just moved the topic to the Document Types - DITA forum.


Regards,
Sorin

Re: Including javascript in webhelp topic head

Posted: Wed Aug 21, 2013 4:22 pm
by kmank
I appear to have three different instances of "</head>", none at line 246. They appear at lines 119 (template-create-toc-file), 327 (template-create tocWDiv file) and 617 (template-create index file). None of them appear to be the location I am looking for.

Is there another being used for version 15.0, build 2013062614?

Re: Including javascript in webhelp topic head

Posted: Wed Aug 21, 2013 4:45 pm
by sorin_ristache
Hi,

In version 15.0 the XSLT stylesheets for the Webhelp transformation were refactored. You can inject your own JavaScript code in the header of each topic by adding it in the template called "jsAndCSS" in the file [Oxygen-15-install-dir]\frameworks\dita\DITA-OT\plugins\com.oxygenxml.webhelp\xsl\dita\desktop\common.xsl.


Regards,
Sorin

Re: Including javascript in webhelp topic head

Posted: Wed Aug 21, 2013 11:22 pm
by kmank
That's the spot - thanks very much!