law
law

Reputation: 23

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...

Upvotes: 1

Views: 7416

Answers (2)

M Gaidhane
M Gaidhane

Reputation: 531

Hey check out for this may be it will helpful for you
<?php echo CHtml::link('Link Text','http://google.com', array('target'=>'_blank')); ?>

Upvotes: 1

Maerlyn
Maerlyn

Reputation: 34107

You cannot redirect in a new tab like this, as there's no way to specify the target in the Location http header.

A possible workaround is to output a form and submit it immediately with 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.

Upvotes: 1

Related Questions