Is there a way to write this in the fluid template?
<a onclick="history.back()">Back</a>
I have tried these options and they do not work:
<a onclick="history.back()">Back</a>
<f:format.raw><a onclick="history.back()">Back</a></f:format.raw>
<f:link.typolink parameter="1" additionalAttributes="{onclick: 'history.back()'}">Back</f:link.typolink>
All versions only result in the word “Back” or a link without an "onclick"
The problems are caused by the HTMLSanitizer.
Some information can be found here https://punkt.de/de/blog/2021/htmlsanitizer-in-typo3.html (german).
in my case, i have created the following sanitizer
use TYPO3\CMS\Core\Html\DefaultSanitizerBuilder;
use TYPO3\HtmlSanitizer\Behavior;
use TYPO3\HtmlSanitizer\Behavior\Attr;
use TYPO3\HtmlSanitizer\Behavior\Tag;
class HjuHtmlSanitizer extends DefaultSanitizerBuilder
{
public function createBehavior(): Behavior
{
$behaviour = parent::createBehavior()
->withName('hju-custom-a')
->withTags(
(new Behavior\Tag('a', Behavior\Tag::ALLOW_CHILDREN))
->addAttrs(
(new Behavior\Attr('href'))->addValues(
//to filter values
//new Behavior\RegExpAttrValue('#^https?://#')
),
(new Behavior\Attr('onclick'))->addValues(),
(new Behavior\Attr('target'))->addValues(),
...$this->globalAttrs
),
(new Behavior\Tag('span', Behavior\Tag::ALLOW_CHILDREN))
->addAttrs(
(new Behavior\Attr('onclick'))->addValues(),
...$this->globalAttrs
)
);
return $behaviour;
}
}