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
saiisaii 

How can I close the Existing window

Hi

I am able Open A new Window On click On the Button .but i want close the existing window  when i click on that button .but am not able to close an existing window.

I have tried window.close() but not working can u please help me

<script type="text/javascript">
function myFunction()
{

 window.open ("https://www.google.com/","mywindow","menubar=1,resizable=1,width=8000,height=9000");
 window.parent.close();    // not working
}

</script>

I have created a new tab to execute the Page . i want close my existing window

thanks in advances

bob_buzzardbob_buzzard

Generally speaking, browsers only like a window to be closed via javascript if the window was opened via javascript, as its not a great user experience to have windows disappearing unexpectedly.

saiisaii

Hi i am able to close the Parent window in Internet  Explorer.

But my Javascript  code is not working in the googlechrome  and mozilla firefox.

<!--Script to close the Parent window--->

<script type="text/javascript">
function CloseAndRefresh()
{
window.parent.close();
}
</script>

can  U help me to work in all browser 

 

 

 

 

thanks in advances

 

bob_buzzardbob_buzzard

This goes back to my point that browsers generally don't allow this behaviour.  Some will, some won't.  I doubt you'll be able to force a browser to behave in a way that the designers didn't want it to.

ve krve kr
Hi Bob , I have faced the same problem in the below code
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}

var qr = sforce.connection.query("SELECT Id, Status FROM Case where Id='" + "{!Case.Id}" + "'");
var records = qr.getArray("records");





var o = new sforce.SObject("Case");
o.id = "{!Case.Id}";


o.Status = "Closed";


sforce.connection.update([o]);

window.parent.close();


It is working to close the parent window in IE and Chrome nut it's not working in the Mozilla. How can I solve this issue .

Thanks,