Using JavaScript:
<apex:page showChat="false" wizard="true" sidebar="false" >
<!-- Javascript -->
<script type = "text/javascript">
function winClose()
{
self.close();
}
</script>
<!-- End of Javascript-->
<apex:commandButton onComplete = "winClose();">
</apex:page>
Using Apex PageReference :
public PageReference method(){
if(variable== null || variable == ''){
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please enter variable'));
return null;
}else{
return new PageReference('javascript:window.close()');
}
<apex:page showChat="false" wizard="true" sidebar="false" >
<!-- Javascript -->
<script type = "text/javascript">
function winClose()
{
self.close();
}
</script>
<!-- End of Javascript-->
<apex:commandButton onComplete = "winClose();">
</apex:page>
Using Apex PageReference :
public PageReference method(){
if(variable== null || variable == ''){
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please enter variable'));
return null;
}else{
return new PageReference('javascript:window.close()');
}