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
Frank CarterFrank Carter 

vf page/ javascript - return previous page

Hello,

I need help.
I have a custom button on Opportunity record page that opens a vf page with inline Javascript code. I want to know if there is an instruction like "window.location.href =​ " or similar  to make me go back to previous page  (valid for Classic and Lightning). The previous page is a page of an opportunity. 
<apex:page standardController="Opportunity" >
    <script type = "text/javascript"> 
    window.onload=function() 
{

if(('{!Opportunity.StageName}' != "Won"){

window.location.href = '/apex/Involve_PreSales?Id={!Opportunity.Id}';
} 



else 
    
alert("The PreSales has already been involved");

//GO TO PREVIOUS PAGE;

}
};
    </script>  
</apex:page>
Can some one help me?

Thanks,
Frank
 
Raj VakatiRaj Vakati
try this code
 
<apex:page standardController="Opportunity" >
    <script type = "text/javascript"> 
    window.onload=function() 
{

if(('{!Opportunity.StageName}' != "Won"){

window.location.href = '/apex/Involve_PreSales?Id={!Opportunity.Id}';
} 



else 
    
alert("The PreSales has already been involved");

    window.history.back();

}
};
    </script>  
</apex:page>