Related to my earlier post about building a Table of Contents before displaying an HTML stream, I now need to insert into the HTML a "Back to Top" <a> tag for each point where the TOC would take the user.
Now, I have been able to do this successfully, the code is below. My question is how can I change the size of the displayed text, "Back to Top". I tried:
$newElement->appendChild($domTranObj->createTextNode('<font size="-2">Back to Top of Label</font>'));
But all that happened is the font codes ended up being printed as entered.
Any idea what I am doing wrong?
My code:
foreach ($linkPairs as $key=>$value)
{
$elements = $xpath->query('//a[@name="'.$value.'"]/following-sibling::h1[1]');
if (count($elements) > 0) {
foreach ($elements as $anode) {
$newElement = appendSibling(new DOMElement('a'),$anode);
$newElement->setAttribute("href","#toc");
$newElement->appendChild($domTranObj->createTextNode('<font size="1">Back to Top of Label</font>'));
}
}
}