I too stuck in a similar issue, I am calling a visualforce page from a javascript button, button's code is as
window.open('/apex/addNaratives?id={!Lead.Id}&retURL=/apex/ForceWindowClose', 'Popup Name' ,"width=700, height=580, scrollbars=yes")
it is opening a new window as desired, id also being passed,
now I want this, once the button on this visualforce page "Save" record which actually saving this record, is clicked the javascript window should close and it should redirect me to the Narrative detail record page.
visualforce page code is as
<apex:form >
<apex:pageBlock mode="edit" title="The Insurance Agency, Inc">
<apex:pageblockButtons location="bottom">
<Apex:commandButton value="Save" action="{!saveRecord}" />
</apex:pageblockButtons>
<br/>
The narrative should answer the following topics to validate the information gathered and provide for others
a comprehensive understanding of the agency.
<br/><br/><br/>
<apex:pageBlockSection columns="1" title="Add Narrative" >
<apex:inputtextarea value="{!Nar.History__c}" label="History" cols="80" rows="6" required="true"/>
<apex:inputtextarea value="{!Nar.Operational_Summary__c}" label="Operational Summary" cols="80" rows="6" required="true"/>
<apex:inputtextarea value="{!Nar.Needs_Analysis__c}" label="Needs Analysis" cols="80" rows="6" required="true"/>
<apex:inputtextarea value="{!Nar.History__c}" label="Conclusions" cols="80" rows="6" required="true"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>