简体   繁体   English

Yii Framework PHP重定向到新选项卡中的外部链接?

[英]Yii Framework PHP redirect to external Link in new tab?

Hi what i essentially want to achieve is a redirect to an external link in a new tab right now I've got: 嗨,我本质上想要实现的是现在我已经有了一个重定向到新标签中的外部链接的功能:

$this->redirect('http://www.google.com', array('target'=>'_blank'));

Which redirects but not in a new tab... 哪个重定向但不在新标签中...

You cannot redirect in a new tab like this, as there's no way to specify the target in the Location http header. 您无法在这样的新标签页中重定向,因为无法在Location http标头中指定目标。

A possible workaround is to output a form and submit it immediately with JS: 可能的解决方法是输出表单并立即使用JS提交:

<form action="http://www.google.com" method="get" target="_blank" id="myform"></form>
<script>
  document.getElementById("myform").submit();
</script>

Note that you'll somehow need to hide it in your main content, that appears in the current tab. 请注意,您将需要以某种方式将其隐藏在当前标签中的主要内容中。

嘿,看看这可能对您有帮助
<?php echo CHtml::link('Link Text','http://google.com', array('target'=>'_blank')); ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM