0

I have a admin controller which redirects to an external url using the following code

public function indexAction()
{
$url = 'http://www.example.com/';
    $this->getResponse()->setRedirect($url);
}

Is there anyway to change this so it opens the link into a new window as opposed to redirecting the current page?

2

This is not possible from the server side. What I would suggest is call the action via ajax and then on success write some JavaScript that opens a new tab (note that some browsers will open a new tab and some will open a new window from JavaScript).

If you want to return json from your action the following lines would help.

$this->getResponse()->setHeader('Content-type', 'application/json');
$this->getResponse()->setBody(json_encode($json));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.