6

How to create a popup window in admin panel?

I want to open a popup window when a custom button on the sales/order page is clicked to show details to the customer.

1

You have two options:

Popup window

Magento has a shortcut JavaScript function for popup windows, defined in js/varien/js.js:

function popWin(url,win,para)

The parameters are the same as in window.open

Example:

popWin(
    "http://www.domainname.ext/path/ImageFile.png",
    "DescriptiveWindowName",
    "resizable,scrollbars,status")

Popup layer

In the admin area you have also access to the prototype.js Window plugin that can open a layer with control elements and arbitrary content, which can be an external URL. In that case it is loaded into an iframe.

Example:

var url ='http://www.domainname.ext/path/ImageFile.png'
var win = new Window({
    className:'magento',
    title:'Enter Window Title',
    url:url,
    width:820,
    height:600,
    minimizable:false,
    maximizable:false,
    showEffectOptions: {duration:0.4},
    hideEffectOptions:{duration:0.4}
});
win.setZIndex(100);
win.showCenter(true);

It's also possible to load the window content via AJAX instead of in an iframe, see: Window.setAjaxContent()

0

This should work

<a href="javascript:window.open('document.aspx','mywindowtitle','width=500,height=750')">open window</a>

If you desire more complex functions, use the php variable "GET"
Using "POST" can be a bit tricky with Backend HTTP/1.1 Validation.

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.