You need to sign in to do that
Don't have an account?
Can not close Pop-up VF page
Hello
I have popup vf page which is opened by custom button. It uses standard controller with extension. And the problem is that it uses standard save() method and it never closes. I tried to apply solution from here
http://boards.developerforce.com/t5/Visualforce-Development/Closing-Popup/m-p/187900/highlight/true
but it doesn't work. The javascript function is loaded and passes if-condition but the window is not closed. Here is my code, maybe someone have an idea what's the problem is:
<apex:page standardController="Opportunity" extensions="PPOppWonController"
sidebar="false" showHeader="false" standardStylesheets="false" wizard="false" id="pg" >
<html>
<head></head>
<body onload="checkStatus();"></body>
</html>
<apex:form id="frm" >
<table>
<tr>
<td valign="top">
<apex:inputTextarea id="sReasonWon" value="{!sReasonWon}" cols="35" rows="5"
onkeypress="return disableEnterKey(event)"></apex:inputTextarea>
<apex:inputHidden id="stat" value="{!sStatus}" />
</td></tr>
<tr> <td>
<apex:commandButton action="{!save}" id="btn" value="Request Won " />
</td>
</tr>
</table>
<script>
var btn = document.getElementById("{!$Component.btn}");
var sts = document.getElementById("{!$Component.frm.stat}");
</script>
</apex:form>
<script type="text/javascript">
function disableEnterKey(e)
{
var key;
if(window.event)
key = window.event.keyCode; //IE
else
key = e.which; //firefox
return (key != 13);
}
function checkStatus(){
if(sts.value == 'saved'){
self.close();
} }
</script>
</apex:page>
Thank you in advance! Any help is welcome
I solved it by using window.top.close(); instead of self.close();
All Answers
I solved it by using window.top.close(); instead of self.close();
You can also use window.parent.close() or window.close().