You need to sign in to do that
Don't have an account?
Damien_
window.close(); not working
I have a page that has a button that calls window.close(); in javascript. For some reason the window.close(); never gets executed and i cannot figure out why. I have tried in ie, firefox and chrome browsers and none will work.
<apex:page controller="CustAcctAlertDetailController" sidebar="false" showHeader="false" standardStylesheets="false">
<style>
body{background-color: LightGrey;}
</style>
<apex:form >
<div>
<apex:outputPanel >
<span style="font-size:20px;font-weight:bolder;">Alert Details</span>
<span style="font-size:12px">
<table>
<tr>
<td width="90px"><apex:outputText value="{!details.detailAccountID}" /></td>
<td><apex:outputText value="{!details.subAcctName}" /></td>
</tr>
<tr>
<td><apex:outputText value="{!details.msgCategory}" /></td>
<td>address line 2</td>
</tr>
<tr>
<td /><td>address line 3</td>
</tr>
</table><br/>
<span style="font-size:19px;font-weight:bolder;">Subject: {!details.msgSubject}</span>
<table>
<tr>
<td width="75px">Date:</td>
<td>{!details.msgCreateDate}</td>
</tr>
<tr>
<td>Alert Type:</td>
<td width="250px">{!details.msgAlertType}</td>
<td width="90px">Master Account:</td>
<td>{!details.masterDetailAccountID}</td>
</tr>
<tr>
<td>Priority:</td>
<td>{!details.msgPriority}</td>
<td>Status:</td>
<td>{!details.status}</td>
</tr>
<tr>
<td>Alert ID:</td>
<td>{!details.alertID}</td>
<td>Action:</td>
<td>Not Required</td>
</tr>
<tr>
<td>Task ID:</td>
<td>N/A</td>
</tr>
</table><br/>
<span style="font-size:19px;font-weight:bolder;">From: {!details.msgFromName}</span><br/>
<span style="font-size:19px;font-weight:bolder;">Comment:</span><br/> {!details.msgText}
<br/><br/>
If you have any questions, please Contact your Service Team.<br/><br/>
</span>
<table>
<tr>
<td style="border:2px dashed orange;background-color: White;font-size:12px;">
Action is required on check and journal requests by 12:00 noon ET on the requested pay date to ensure payment. Moneylink requests
require action one business day before the requested pay date.<br/>
You may update the transaction online, place trades online, as needed, or for assistance resolving this issue please contact your service
or trading team.<br/>
<apex:outputLink value="" style="color:blue;">Go to Schwab Advisor Center</apex:outputLink>
</td>
</tr>
</table>
</apex:outputPanel>
<table width="100%">
<tr>
<td><apex:commandButton value="Archive" style="width: 100px;" /></td>
<td style="text-align: right;">
<apex:commandButton value="Close" style="width: 100px;" onClick="window.close();" />
<input value="Close" type="button" style="width: 100px;" onClick="window.close();" /></td>
</tr>
</table>
<apex:actionSupport />
</div>
</apex:form>
<script type="text/javascript">
function myclose()
{
window.close();
return false;
}
</script>
</apex:page>
Typically browsers will only allow the page that spawned a window to close it, although some older browsers are a little lax. There are various functions attempting to work around this on the web, but I've not found any that work reliably across all browsers.
The thing is, I have found pages that open a new window, then the new window has a button to close itself. I tested these examples in my browser and they worked. I followed those examples for my page and it doesn't work. I'm wondering if Salesforce did something to interfere with it.
I've found that the page that opens the new window needs to expose a javascript method to allow it to be closed. I'd be surprised if Salesforce are able to interfere at that level - window.close is a straightforward javascript call.
<apex:commandButton value="Search Again" onclick="return window.open('/apex/customreport');window.top.close();" />
it is opening one new window and the old window is also there .
when the button is clicked it has to close the current window and apen the new window which i wrote above .answer would be great helpful