0

我想在 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');
                    ");
}
4

1 回答 1

1

for的第二个参数window.open()是windowName,您似乎在尝试通过提供目标来打开新选项卡的上下文中使用它 as _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');
");
}
于 2020-07-20T18:17:35.863 回答