Yii CGridView 超链接在新标签页中打开 [英] Yii CGridView hyperlink open in new tab

查看:36
本文介绍了Yii CGridView 超链接在新标签页中打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将我的 yii CGridview 的一列作为超链接.但是单击它时,它会在同一选项卡中打开链接地址.如何在新标签页中打开链接地址?

I have made one column of my yii CGridview as a hyperlink. But on clicking it, it opens link address within the same tab. How can I open the link address in a new tab ?

array(
    'header'=>'Name',
    'name'  => 'name',
    'value' => 'CHtml::link($data->name, $data->site_url)',
    'type'  => 'raw',
),

推荐答案

target 属性设置为 _blank 用于链接 (代码>) 将生成:

Set the target attribute as _blank for the link (<a>) that will be generated:

<a href="some_url" target="_blank">Foo</a>

使用 CHtml::link :

'value' => 'CHtml::link($data->name, $data->site_url, array("target"=>"_blank"))',

CHtml::link()(以及 CHtml 类中的大多数其他 html 助手)的最后一个参数是 htmlOptions,它应该是一个关联数组,以 html 属性作为键及其值作为值:

The last parameter to CHtml::link() (and most other html helpers in CHtml class), is htmlOptions, which is supposed to be an associative array with html attributes as keys and their values as values:

array(
    "target"=>"_blank",
    "class"=>"my-css-class",
    // ... any other html attribute ..
)

这篇关于Yii CGridView 超链接在新标签页中打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆