0
<aura:component  implements="ForceCommunity:availableForAllPageTypes">
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <div class="slds-var-p-around_xx-large">
        <div class="slds-grid slds-gutters slds-align--absolute-center">
            <div class="one" id="anchor-name">
                <a href="https://www.google.com#anchor-name">
                    <div class="slds-col" style="width:400px;height:300px;">               
                        <div class="slds-align_absolute-center" style="width:380px;height:300px; ">
                            <span class="slds-text-color_inverse">Click here to Access Humira Program</span>          
                        </div>         
                    </div>
                </a>           
            </div>
            <div class="one">
                <a href="https://www.yahoo.com">
                    <div class="slds-col" style="width:400px;height:300px;">               
                        <div class="slds-align_absolute-center" style="width:380px;height:300px; ">
                            <span class="slds-text-color_inverse">Click here to Access Skyrizi Program</span>          
                        </div>         
                    </div>
                </a>    
            </div>

        </div>
    </div>
</aura:component>

1 Answer 1

1

There is known issue with anchor tag href attribute. You should use navigation service instead. You can check documentation here.

Don’t hard code or dynamically generate Salesforce URLs in the href attribute of an tag. Use events, such as force:navigateToSObject or force:navigateToURL, instead.

Using the href attribute of an tag leads to inconsistent behavior in different apps and shouldn’t be relied on.

Use the navigation service for consistent linking behavior across Lightning Experience, Salesforce app, and Lightning communities.

Update after checking code:

Below code is working in community portal.

<aura:component  implements="ForceCommunity:availableForAllPageTypes">
    <aura:attribute name="url" type="string" default="https://www.google.com#anchor-name" />
    <div class="slds-var-p-around_xx-large">
        <div class="slds-grid slds-gutters slds-align--absolute-center">
            <div class="one" id="anchor-name">
                <a href="{!v.url}">
                            <span>Click here to Access Humira Program</span>          
                </a>           
            </div>
            <div class="one">
                <a href="https://www.yahoo.com">
                    <div class="slds-col">               
                      Click here to Access Skyrizi Program
                    </div>
                </a>    
            </div>

        </div>
    </div>
</aura:component>
2
  • Hi @Dhanik, Does this advice apply to links to public external web sites such as https://www.google.com here?
    – Keith C
    Commented Jul 7, 2019 at 14:07
  • I feel, It is not written in documentation. But in one of post sfdxfox mentioned that it will not create issue in external source. So not sure about it. Commented Jul 7, 2019 at 14:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .