Chtml::link And New Window (Not New Tab!)

hi all

is there an easy way to get CHtml::Link to pop a new window and not just a new tab?

by adding this at the end it will create a new tab but I would like it to pop up as brand new browser window\\


array('target'=>'_blank')

everything I’ve seen online simply calls to use the _blank setting… .but that only generates a new tab

thanks

You can’t control this with the target attribute.

Use Javascript instead.

http://www.quirksmode.org/js/popup.html

right… .but how could you incorporate the into the CHtml::Link ?

You can use the onclick event to execute javascript.

So something like:


CHtml::link("blabla",$url,array('onclick'=>new CJavaScriptExpression('return popitup(this.attributes.item("href").value);'));

[size="2"]and make sure that popitup is included somewhere. (popitup was provided on the previous link).[/size]

cool…thanks, I’ll try tonight!

I made some tests and apparently (for chrome), indicating that you do not want the menu bar is sufficient to get a popup:

Sample html code that would work:


<a href="#" onClick="MyWindow=window.open('http://www.yiiframework.com','MyWindow','toolbar=no,location=yes,directories=yes,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=600,height=300'); return false;">PLACE_YOUR_LINKTEXT_HERE</a>

So improved, lighter, Yii version (tested on chrome)::


echo CHtml::link("YII FRAMEWORK","http://www.yiiframework.com",array('onclick'=>new CJavaScriptExpression("window.open(this.attributes.getNamedItem('href').value,'WindowTitle','menubar=no');return false;")));