function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RajiiiRajiii 

How to close ModalDialog in javascript

Hi,

   I have created the visualforce page for some our requirement, using the javascript i will show the child window using through the given below code.

  <apex:page standardController="Shipment_Detail__c" extensions="editSerialNumber" tabStyle="Shipment_Detail__c">

  <script>

  function showModalWindow(number)
           {
             window.showModalDialog("/apex/VFPopupSerial?"+number,'',"resizable: yes");
           }

  </script>

 

<apex:image styleclass="lookupIcon" id="theImage1" onclick="showModalWindow('{!details.Id}')" style="cursor: pointer;  cursor: hand;" value="/s.gif" rendered="true">

 

the given below another visual force page for child window

 

<apex:page Controller="SerialPopup" wizard="true">

    <script>

      function Close()

        {          

          window.close();

        }

    </script>

    <apex:form >

        <apex:pageBlock >

            <apex:pageBlockTable value="{!Items}" var="d">

                <apex:column headerValue="Serial Numbers">

                     <a value="{!d.Name}" style="cursor: pointer; cursor: hand;" onclick="javascript.window.close()">{!d.Name} </a>                        

                </apex:column>

            </apex:pageBlockTable>

        </apex:pageBlock>

    </apex:form>

</apex:page>

 

i need child window is to be close the on click event for list of values in child window. but the child window never closed. i have used window.close(); and also self.close(); how to close that window.. please help

 

Thanks in advance.

 

Best Answer chosen by Admin (Salesforce Developers) 
kiranmutturukiranmutturu

try this

 

some times if the development mode is on window.close will not work... just off that mode and try once , 

 

 

 

 

 

 

All Answers

kruti tandelkruti tandel

Hi,

instead of  "javascript.window.close() ", you need to write down  onclick="window.close()"

bob_buzzardbob_buzzard

An additional word of caution - some browsers don't like windows being closed from a page that didn't open them.  In this case you open the popup from your parent page, but close it via javascript on the child page, which may not work reliably.

 

I've ended up adding a javascript function on the parent page to close the child page (that it opened).  Something to bear in mind if your page is refusing to close once you've fixed any javascript issues.

kiranmutturukiranmutturu

try this

 

some times if the development mode is on window.close will not work... just off that mode and try once , 

 

 

 

 

 

 

This was selected as the best answer
Shashikant SharmaShashikant Sharma

Cjange this 

 

onclick="javascript.window.close()" to onclick="Close();"

 

 

RajiiiRajiii

Hi..

  Thanks for all... I just uncheck the development mode. It works fine....

Mustafa ZaidiMustafa Zaidi

I am facing a problem in Show Modal Dialog in Internet Explorer. I have button and i used below javascript to open the VF page in Popup window. It perfectly work fine on Mozilla Firefox but in Internet Explorer the VF page opens as a Popup and in that VF Page i have a button which query to the Product and fetch all the product in the VF page. but when i click on this button the New window is open (In Mozilla It works fine).

***********************


window.showModalDialog(url,'Contractual Pricing Viewer','dialogHeight: 500px; dialogWidth: 700px; dialogTop: 150px; dialogLeft: 150px; edge: Raised; center: No; help: No; scroll: No; status: Yes;');

 

***************

 

Any Idea why the New window is open in Internet explorer instead of giving me a result in the popup VF Page.