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
Tonima Mallick 7Tonima Mallick 7 

On button click open url


I am facing issue in my code.I want that simply on button click open any url(www.google.com)
Here is my code
User-added image
//------COMPONENT--------//
<aura:component implements="force:appHostable" access="global" controller="ValidateButton1">
   
    <!--<ui:button class="abc" label="Validate"  press="{!c.navigate}"  />-->
 <ui:button class="abc" label="Validate"  press="{!c.navigateToRecord}"  />
</aura:component>

//----------------CONTROLLER-----------------//
({
    doInit : function(component, event, helper){
        console.log('1324');
        console.log('id'+component.get("v.recordId"));
    },
  
    navigateToRecord : function (component, event, helper) {
   helper.navigateToRecord(component);
        },
    
})
//---------------------HELPER------------------//

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

Thanks in advance
please help me out
Best Answer chosen by Tonima Mallick 7
sfdcMonkey.comsfdcMonkey.com
ohh thats it
This event is handled by the one.app container.  It’s supported in Lightning Experience and Salesforce1 only.
app.app is not supported this event here you can use directly
like
({
    navigateToRecord : function(component, event, helper) {
       window.open('https://www.google.com');
    
    }
})
thanks
let me inform if my answer helps you

All Answers

Tonima Mallick 7Tonima Mallick 7
yes I have test my app in lighting app
sfdcMonkey.comsfdcMonkey.com
ohh thats it
This event is handled by the one.app container.  It’s supported in Lightning Experience and Salesforce1 only.
app.app is not supported this event here you can use directly
like
({
    navigateToRecord : function(component, event, helper) {
       window.open('https://www.google.com');
    
    }
})
thanks
let me inform if my answer helps you
This was selected as the best answer
Tonima Mallick 7Tonima Mallick 7
Thanks its work now

but if when I added that component in my page then I have use this code?

    navigateToRecord : function() {
        var urlEvent = $A.get("e.force:navigateToURL");
    urlEvent.setParams({
    "url": 'https://www.google.com'
   });
   urlEvent.fire();
    }
})
sfdcMonkey.comsfdcMonkey.com
when you use this component in salesforce lightning tab component , salesforce lightning app builder , lightning communites page  then you can use this code
but not single apps.app application   
thanks