I am trying to add an anchor tag to the message I want to display but I am getting an error message. Am I not doing this right?
String browserRequirementsUrl = "https://test.testing.com";
var someText = new ParagraphElement()
..innerHtml = "Link can be found <a href=${url}>here</a>[1].";
But I get an error message saying
html_dart2js.dart:3614 Removing disallowed attribute <A href="https://test.testing.com">
Any suggestions, how I can do this?
By default in
dart:html
, for security purposes, this is disallowed.You can use the
.setInnerHtml
method:Note that this can potentially be insecure (i.e. inject
<script>
tags and such), so you can always create a custom sanitizer or validator to only allow a subset of HTML tags (such as<a>
).