I'm not sure how to add the target=_blank to my code below. I am using Codeigniter and my image below contains an external link and works like a charm. I would love to have it open in a new window or tab but I'm unsure how to do it. I haven't found anything so far of anyone else using this method. Any suggestions are appreciated. Thanks
<?php
echo anchor(
'http://www.facebook.com',
img(array(
'src'=>base_url().'images/facebook.png',
'width'=>'32',
'height'=>'32',
'id'=>'facebook',
'alt'=>'Facebook Logo'
))
);?>
Err, pass the attribute as the third argument to anchor()
<?php
echo anchor(
'http://www.facebook.com/artisticconcretegroup',
img(array(
'src'=>base_url().'images/facebook.png',
'width'=>'32',
'height'=>'32',
'id'=>'facebook',
'alt'=>'Facebook Logo'
)),
['target' => '_blank'] // or array('target' => '_blank') if PHP < 5.4
);?>
Or even more simply, use the code you have but with the anchor_popup()
function.
It's all in the docs - http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html
simply add 'target="_blank"'
eg. echo anchor("url",'click here','target="_blank"')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.