Hello, I have following problem with button and link where it redirects. Here is my button code:

$block->addButton('label', array(                           
                          'label' => 'Get Label',
                        //'onclick'   => ((Mage::app()->getResponse()->setRedirect(Mage::helper("adminhtml")->getUrl("/label/setlabel")))),
                          'onclick'   => 'popWin();'                       

I want open in new window my controller, for that I am using 'onclick' => 'popWin();' and this opens new window, but if I am adding 'onclick' => ((Mage::app()->getResponse()->setRedirect(Mage::helper("adminhtml")->getUrl("/label/setlabel")))), it redirects me to controller page before I can even push button, as soon as I open the page where this button is, it automatically redirects me to controller page and doesn't show the page where the button is. How can I open the page where the button is and then click button and then it redirects to controller?


Try setting the onclick like this:

$url = Mage::helper("adminhtml")->getUrl("/label/setlabel");
"onclick" => "popWin('.$url.')"

I hope I got the quotes right.

  • tried, but when i click button happens - just nothing – user6398 May 19 '14 at 8:51
  • if i do var_dump, i can see that the link is correct and link is also working – user6398 May 19 '14 at 9:02
  • works if delete points like this: "onclick" => "popWin('$url')" – user6398 May 19 '14 at 9:06
  • @user6398. Sorry for that. In my defense, I said to check the quotes :D – Marius May 19 '14 at 9:07

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.