Page 1 of 1

How to link external javascript file in a DITA-OT HTML5 output

Posted: Fri Jul 09, 2021 12:04 pm
by gevinl
I would like to add a link to an external JavaScript file in my DITA-OT output HTML5 file, how do I achieve this?

|--[js]
| |--custom.js
|--[css]
| |--custom.css
|--index.html
|--topic01.html
|--topic02.html

I want to add a line <script src="custom.js"></script> in the <head> tag of an output html file.

Please advise.

Thank you.


Gevin

Re: How to link external javascript file in a DITA-OT HTML5 output

Posted: Fri Jul 09, 2021 12:54 pm
by Radu
Hi Gevin,

There is a transformation parameter named "args.hdf":
https://www.dita-ot.org/dev/parameters/ ... __args.hdf

you can point it to a file containing inside the "<script src="custom.js"></script>" content.
The publishing will not automatically copy the "custom.js" to your output folder though but the HTML files will contain the updated header.

Regards,
Radu

Re: How to link external javascript file in a DITA-OT HTML5 output

Posted: Mon Jul 12, 2021 6:22 am
by gevinl
Hi Radu,

Thank you very much for your suggestion.

Yes, it is really work, and solve my problem.

P.s. I uses the example I found in https://www.dita-ot.org/dev/topics/html ... cript.html to write the XML file for args.hdf. It's working.


Cheers!

Gevin

Re: How to link external javascript file in a DITA-OT HTML5 output

Posted: Tue Jul 13, 2021 5:32 am
by gevinl
Radu wrote: Fri Jul 09, 2021 12:54 pm
There is a transformation parameter named "args.hdf":
https://www.dita-ot.org/dev/parameters/ ... __args.hdf

you can point it to a file containing inside the "<script src="custom.js"></script>" content.
The publishing will not automatically copy the "custom.js" to your output folder though but the HTML files will contain the updated header.
Hi Radu,

After successfully using "args.hdf" in my HTML5 transformation, I tried to use same method for 'DITA Map EPUB' transformation. But the transformation fail to add a line in the <head> tag in the pages of the output EPUB.

I did try to use args.hdr and args.ftr, but all fail to write any code within the output pages too.

Do you have any idea?

Thanks & regards,

Re: How to link external javascript file in a DITA-OT HTML5 output

Posted: Thu Jul 15, 2021 6:59 am
by Radu
Hi,

I reproduced the problem and added an internal issue to investigate this further, if I come up with a possible fix I will reply back on the thread.
In the meantime if you use Oxygen's Archive browser view to edit the XHTML documents from the EPUB archive and add the extra javascript inside them, does that work in an EPUB reader? Because there may be limitations related to this as well.

Regards,
Radu