<?xml version="1.0" encoding="UTF-8"?>
<outline xmlns="http://wkhtmltopdf.org/outline">
<item title="" page="0"/>
<!-- Note: I want to pass the substring of the item title (e.g. 'JPN') to JS -->
<item title="language_title:JPN" page="1">
<item title="Table of Contents" page="2"/>
</item>
<item title="document" page="2">
<item title="introduction" page="1">
<item title="Chapter1" page="2">
<item title="Section1" page="3"/>
</item>
<item title="Chapter2" page="4">
<item title="Section2" page="5"/>
</item>
</item>
</item>
<item title="" page="20"/>
</outline>
我认为您当前的代码在定义该函数之前试图调用该函数,将代码更改为例如。
<script type="text/javascript">
<!-- Note: call the following function to update the TOC header based on language title -->
document.addEventListener('DOMContentLoaded', function(evt) { updateTOCHeader("<xsl:value-of select="$language_title"/>"); });
</script>
该函数首先定义,然后在加载DOM后稍后被调用。