0

Is there a way to create an empty link in D8? What I want specifically is

<a href="javascript:void(0)">Link</a>

Url::fromUserInput('#', ['fragment' => '#']) creates an anchor tag with ## link.

Thanks

3
  • 2
    Possible duplicate of Create a link pointing to # – Menno van den Heuvel Aug 30 '18 at 18:38
  • Might not be. The solution in the link creates a # link. I want a javascript: void(0) linked anchor tag. – Pratip Ghosh Aug 31 '18 at 3:38
  • 1
    Because of what you tried I thought it might be. Either way, I expect the answer will be the same: use an inline or twig template to do this. The Url class - from a cursory glance at the source - I don't think will generate a javascript url. – Menno van den Heuvel Aug 31 '18 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.