I have an embedded Visualforce page that contains some Javascript code. The purpose of the code is to open a custom VF page once the Stage of an Opportunity reaches a certain point. I want this to occur only when the Opportunity Stage is changed to a particular stage. The problem I am running into with the code below is that the Javascript executes every time the page of that Opportunity is refreshed, as long as it remains in the particular Stage. I tried using a Workflow rule to mark a checkbox, but the WF fires before the Javascript executes, so the conditions are never met. Is there any way to get this Javascript to execute only when the Opportunity Stage is moved to Stage 4 an not just when it shows up as Stage 4? Thanks,
<apex:page standardController="Opportunity">
<script type="text/javascript">
if("{!Opportunity.StageName}" === "{!$Label.Eng_OppStage4}"
{
window.open("/apex/DealSummaryInitialTestOpp?Id={!Opportunity.Id}","_blank");
}
</script>