Question

I have one question, please.

Now I'm using ShowModalDialog method to display Popup.

It doesn't display Menu Bar (File,Edit,...) in Popup. I need to show Menu Bar in Popup because I want to click 'Print' under File menu.

I can't find a way to see the Menu Bar in Popup using ShowModalDialog. Is it possible to display the menu bar and how should I write in JavaScript coding like menubar: yes?

I wrote the code as the following.

<script>
    /*
    * ShowModalDialog
    */
    function popupWindow(x_URL, x_ARG, x_WIDTH, x_HEIGHT){
        var x_OPT = "dialogHeight: "+x_HEIGHT+"px; "
        +"dialogWidth: "+x_WIDTH+"px; "
        +"edge: Raised; center: Yes; resizable: Yes; status: Yes;";
        window.showModalDialog(x_URL, x_ARG, x_OPT);
    }
</script>
<s:url id="printURL" action="myaction" method="print"></s:url>
<s:submit name="btn_print"
value="Print"
onclick="popupWindow('%{printURL}','',1200,600);return false;" />

Thanks in advance.

Was it helpful?

Solution

It is not possible to make the web browser show a menu bar when using window.showModalDialog (see references at MDN and MSDN). However, you can create your own print button inside the modal window like this:

<button type="button" onclick="window.print();">Print</button>

The key there is the call to window.print().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top