[SalesForce] How to navigate to VF page from a lightning component with javascript

I have a button in a lightning component onclick of which I want to navigate to a visualforce page (which will open in lightning experience only). Is this possible with javascript? If yes, then how can I do it?

Best Answer

By using navigatingToURL

In Component

<aura:component implements="force:appHostable,force:lightningQuickActionWithoutHeader,flexipage:availableForAllPageTypes" access="global" >
        <ui:button label="navigateToURL" press="{!c.gotoURL}" />
</aura:component>

In controller

gotoURL : function(component, event, helper) {
    var urlEvent = $A.get("e.force:navigateToURL");
    urlEvent.setParams({
        "url":"vfpage url"
    });
    urlEvent.fire(); }