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

  • 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();
    }

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos

Salesforce Interview Questions and Answers - For Freshers and Experienced Candidates

Video in

Learn most important Salesforce Interview Questions and Answers, asked at every interview. These Interview questions will be useful to all entry-level candidates, beginners, interns, and…