Activity Forums Salesforce® Discussions URL Navigation in salesforce classic vs lightning

  • PRANAV

    Member
    April 26, 2018 at 4:37 pm

    When I click on home button in my visualforce page(/home/home.jsp) in lightning, it doesn't works, Why?

  • Manpreet

    Member
    April 26, 2018 at 4:43 pm

    Hi pranav,

    You need to use the following script to differ salesforce classic from lightning environment :

    <script>
    function homeBtn(){

    if( (typeof sforce != 'undefined') && sforce && (!!sforce.one) ) {
    // Lightning navigation - Salesforce navigateToURL
    sforce.one.navigateToURL('/home/home.jsp');
    }
    else {
    // Set the window's URL using a Visualforce expression
    window.location.href = '/home/home.jsp';
    }
    }
    </script>

    Thanks.

  • Aman

    Member
    April 27, 2018 at 9:28 am

    Hi Pranav,

    You can also use Salesforce navigateToURL event to navigate URL In lightning,

    navigate : function(component, event, helper) {

    //Find the text value of the component with aura:id set to "address"
    var address = component.find("address").get("v.value");

    var urlEvent = $A.get("e.force:navigateToURL");
    urlEvent.setParams({
    "url": 'https://www.google.com/maps/place/' + address
    });
    urlEvent.fire();
    }

Viewing 1 - 3 of 3 posts

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos