Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
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.
A possible way out might be like this - $nolink_url = Url::fromUserInput('#', ['fragment' => '#', 'attributes' => ['onclick' => 'return false']]); Though this would not put a javascript: void(0) in place, but will stop the jump to the top which was my actual requirement. :)
#
link. I want ajavascript: void(0)
linked anchor tag.$nolink_url = Url::fromUserInput('#', ['fragment' => '#', 'attributes' => ['onclick' => 'return false']]);
Though this would not put a javascript: void(0) in place, but will stop the jump to the top which was my actual requirement. :)