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
NeetikaNeetika 

JAVASCRIPT : VF page refreshing issue

Hello All,

 

I am facing some issue with Javascript code on custom button.

 

I have custom button to open a Visualforce page it should refresh only on submit or updating value on parent page.

But it is refreshing when we click on cancel custom button on VF page or close by window. 

 

Issue is without changing anything on parent page just closing window refreshing the page this we need to restrict.

 

Any altertive to resolve this issue?

 

Thanks

Neetika

yvk431yvk431

requirement not very clear , can you please elaborate more

 

--yvk

NeetikaNeetika

Hi,

 

I have one custom button on case that opens a VF page as a popup window.

 

 

It have three options to close that VF page popup - "Submit" where some update I am doing on case button after submitting, then "Cancel" button by which without doing anything it will close the VF page and third one by "window close".

 

My Requirement is to refresh the Parent Page on updating the record only when we are closing window by submit button.

 

With my javascript code on button its refreshing the parent page on all three conditions even when we close VF page popup window by window close option.

I want to restrict it to make it refresh in other conditions. Refresh Parent Page on updation only.

How to do that?

Below is the Javascript code for Custom button:

{!REQUIRESCRIPT("/soap/ajax/23.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/23.0/apex.js")} 


var windowRef; 
var intervalId = 0; 


function checkToOpenWindow() 


windowRef = window.open('/apex/WWSOREQuestionPage?Id={!CASESAFEID(Case.Id)}&No={!Case.CaseNumber}&Source=SFDC','mywindow','width=800,height=800,scrollbars=yes'); 
windowRef.moveTo(300,200); 
windowRef.focus(); 
checkWindowStatus(); 
}; 

setTimeout(checkToOpenWindow, 2*1000); 

function checkWindowStatus() 

intervalId = setInterval(checkAndCloseWin, 5*1000); 
}; 

function checkAndCloseWin() 

if(windowRef.closed) 

clearInterval(intervalId); 
window.parent.location.href = window.parent.location.href; 

};

 

Thanks

Neetika