我想在 cjuidialog 中保存后打開新選項卡。我用了window.top.location.href它可以工作,但不能打開新選項卡,但如果我使用window.open('https://api.whatsapp.com/send?phone=+62878787811423&text=Tesdawks', '_blank');它不起作用。這是我的完整代碼<?php $this->beginWidget('zii.widgets.jui.CJuiDialog', array( 'id'=>'cru-dialog', 'options'=>array( 'title'=>'Detail view', 'autoOpen'=>false, 'modal'=>true, 'width'=>'80%', 'height'=>450, 'close'=>'js:function(){ $("#cru-frame").attr("src",""); $.fn.yiiGridView.update("indexKonsumen-grid", { data: $(this).serialize() }); }', ), ));?><iframe id="cru-frame" width="100%" height="100%"></iframe><?php $this->endWidget(); ?>我的控制器if(isset($_POST['wa'])){ echo CHtml::script("window.parent.$('#cru-dialog').dialog('close'); window.parent.$('#cru-frame').attr('src',''); window.open('https://api.whatsapp.com/send?phone=+62878787811423&text=Tesdawks', '_blank'); ");}
1 回答

富國滬深
TA貢獻1790條經驗 獲得超9個贊
第二個參數window.open()是 windowName,您似乎在嘗試通過提供目標來打開新選項卡的上下文中使用它_blank,但是默認行為window.open是在新選項卡中打開窗口,因此這是多余的。
if(isset($_POST['wa'])) {
echo CHtml::script("window.parent.$('#cru-dialog').dialog('close');
window.parent.$('#cru-frame').attr('src','');
window.open('https://api.whatsapp.com/send?phone=+62878787811423&text=Tesdawks');
");
}
- 1 回答
- 0 關注
- 130 瀏覽
添加回答
舉報
0/150
提交
取消