猿问

window.open 在 cjuidialog yii1 内不起作用

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

                    ");

}


慕莱坞森
浏览 115回答 1
1回答

富国沪深

第二个参数window.open()是 windowName,您似乎在尝试通过提供目标来打开新选项卡的上下文中使用它_blank,但是默认行为window.open是在新选项卡中打开窗口,因此这是多余的。if(isset($_POST['wa'])) {&nbsp; &nbsp; echo CHtml::script("window.parent.$('#cru-dialog').dialog('close');&nbsp; &nbsp; window.parent.$('#cru-frame').attr('src','');&nbsp; &nbsp; window.open('https://api.whatsapp.com/send?phone=+62878787811423&text=Tesdawks');");}
随时随地看视频慕课网APP
我要回答