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
Amit Raghuvanshi 6Amit Raghuvanshi 6 

navigatetoURL error in lightning classic

=====> Lightning component <======

<aura:component implements="force:appHostable">
           <ui:button press="{!c.navigateIt}"  label="Go!" />
</aura:component>

======> Lightning Component Controller <======

var navigateIt : function(component,helper,event)
{
        var navigate = $A.get("e.force:navigateToURL");
        navigate.setParams({ "url" : http://www.google.com"});
        navigate.fire();
}

Getting Error : Something gone wrong :Cannot read property 'setParams' of undefined
in lightning classic but working fine in lightning experiance and salesforce 1 

How can i achieve the same in lightning classing using events?

Thanks in advance .... :)
 
Veenesh VikramVeenesh Vikram
Hi Amit,

You need to register an event in order to fire it from your Lightening component.
Register the Application event like this:
=====> Lightning component <======

<aura:component implements="force:appHostable">
			<aura:registerEvent name="navigateToURL" type="c:navigateToURL"/>
			<ui:button press="{!c.navigateIt}"  label="Go!" />
</aura:component>

======> Lightning Component Controller <======

var navigateIt : function(component,helper,event)
{
        var navigate = $A.get("e.c:navigateToURL");
        navigate.setParams({ "url" : http://www.google.com"});
        navigate.fire();
}
Kindly mark this as a solution if it helps!

Regards
Veenesh
ManishKumar Singh 1ManishKumar Singh 1
Any idea to make a custom navigteToURL event?