I am using the following code.
$url = Url::fromUri('javascript:', array('external' => true));
$link = Link::fromTextAndUrl(t("#action"), $url)->toString();
It causes the following error:
InvalidArgumentException: The URI 'javascript' is invalid. You must use a valid URI scheme. in Drupal\Core\Url::fromUri() (line 280 of C:\xampp\htdocs\drupal826\core\lib\Drupal\Core\Url.php).
Is this supported in Drupal 8?
I found How to create an EMPTY anchor-only link with l()? but that is for Drupal 7.
use Drupal\Core\Url;
anduse Drupal\Core\Link;
?use Drupal\Core\Link; use Drupal\Core\Url;
external
, I think you're looking forfragment
and alsojavascript:
is not a URI.<a href="javascript:;">#link</a>
javascript:;
there anyways?