If you want to create a link with just the fragment, you need to "trick" the url function a bit. As it will append the basepath to all internal urls, ''
will become http://example.com
.
What you need to do is to set the external option to true:
l('link', '', array('fragment' => 'namedanchor', 'external' => TRUE));
This will give the desired
<a href='#namedanchor'>link</a>
Alternative you could give the full url like Jeremy suggests.
来自 http://stackoverflow.com/questions/1698453/drupal-creating-anchor-only-link-with-l
10 | 正确答案
|
l(t('View Map & Directions'), $map_address_url, array('attributes' => array('target'=>'_blank')))