Forum How do I...?

Table of contents "0"

rainhallikas
I understand that if the referenced page is not found then the page number becomes "0". Is there a way to set that value to empty or something similar?
mikeday
I think this would require using a prince-script() function with some JavaScript to check the value.
rainhallikas
Got it, thanks.
rainhallikas
I'm having problems. Can't seem to call the Javascript function. I tried a simple content: prince-script(replace) with a simple return function but that did not work either. What am I doing wrong?

CSS:
#table-of-contents a[href]::after { content: leader(".") prince-script(replace, target-counter(attr(href), page)); }

prince-script.js:
function replace(n)
{
    if(n == '0') return '';
    return n;
}

CODE:
prn.AddScript(PrinceScriptLink);
mikeday
You also need to make the script function available to CSS by calling this:
Prince.addScriptFunc("replace", replace);