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
Nethra RaghupathyNethra Raghupathy 

Navigate from one page to another on button click in both Lightning and Classic

Hi,

I want to navigate from one page to another on a button click. It should work for both Lightning and classic.
button.cmp: lightning component
<lightning:button label="View Interview" value="{!row.oppId+'@'+indx}" iconPosition="left" disabled="{!row.interviewFlag}" onclick="{!c.displayInterview}"/>
buttonController.js: lightning controller
displayInterview : function (component, event, helper) {
       
    /*var urlEvent = $A.get("e.force:navigateToURL");
    urlEvent.setParams({
      "url": "/apex/home"
    });
    urlEvent.fire();*/
       
    var action = component.get("c.displayInterviewApex");
        action.setCallback(this, function(data) {
            	console.log(data.getReturnValue());
        });
}
Commented part works for lightning but not in classic.
ButtonController.apxc : Apex controller
public class ButtonController {
public static pagereference displayInterviewApex(){
      system.debug('called');
      Pagereference redirectedPage = New PageReference('/apex/home');  
      return redirectedPage;
   }
}
displayInterviewApex function is not called as its not aura enabled. If I add @AuraEnabled, pagereference is not supported. Is there a way to do for both classic and lightning?