Including javascript in webhelp topic head

Post here questions and problems related to editing and publishing DITA content.
kmank
Posts: 118
Joined: Mon Apr 19, 2010 5:33 pm

Including javascript in webhelp topic head

Post 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?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Including javascript in webhelp topic head

Post 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
kmank
Posts: 118
Joined: Mon Apr 19, 2010 5:33 pm

Re: Including javascript in webhelp topic head

Post 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!! :)
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Including javascript in webhelp topic head

Post by sorin_ristache »

OK, I just moved the topic to the Document Types - DITA forum.


Regards,
Sorin
kmank
Posts: 118
Joined: Mon Apr 19, 2010 5:33 pm

Re: Including javascript in webhelp topic head

Post 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?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

Re: Including javascript in webhelp topic head

Post 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
kmank
Posts: 118
Joined: Mon Apr 19, 2010 5:33 pm

Re: Including javascript in webhelp topic head

Post by kmank »

That's the spot - thanks very much!
Post Reply