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
Serena SchultzSerena Schultz 

Launch new visualforce page from custom button

Hi All,

I'm trying to upgrade a JavaScript button I have in Classic to work in Lightning. In Classic this JavaScript button opens a VisualForce page in a new window with some content populated based on the Parent page that the button is housed on. To migrate this to Lightning I've created a Detail Page Button which displays in a new window and calls a VisualForce Page. 

The VF page that I'm calling opens the page I want just fine, but it is ALSO navigating me away from my parent Detail page (in this case contact). 

Any thoughts on why? Code is below.

THANKS!
 
<apex:page standardController="Contact">
   <script>
       myFunction();
           function myFunction() {
                if ({!NOT( ISNULL(Contact.MobilePhone) )}){ 
                        var url;
                        if('{!$Label.AppName__namespace}' === "none"){
                        url="/apex/" + "SendMessage?contactIDs={!Contact.Id}"+"&contact=1&modal=1"; 
                        } else { 
                        url="/apex/" + '{!$Label.AppName__namespace__namespace}' + "SendMessage?contactIDs={!Contact.Id}"+"&contact=1&modal=1"; 
                        }
                        
                        window.open(url, 'Popup','height=510,width=1200,top=0,left=0,location=no,menubar=no,titlebar=no,toolbar=no,status=no');  
                } 
                else{ 
                    alert ("Mobile Number Missing."); 
                }
            }
   </script> 
</apex:page>