0

My goal is to display articles in a custom LC. I am able to achieve this and article links are clickable. On click of the article link opens the article detail in existing window. Working fine. However, on right click and opening the article link in a new tab, I am getting the blank page with error "about:blank#blocked". How do I facilitate the right click and open in new tab both work.. Thank you.

Code snippet for reference -

Lightning component:

<a> onclick="{!c.gotoArticle}" </a>

Lightning Controller

gotoArticle: function(cmp, event){

        var whichPage       = "/article/";
        var whichArticleId  = event.target.getAttribute('data-id');
        var whichArticle    = event.target.getAttribute('data-value');
        var myURL           = whichPage.concat(whichArticle.toString());
        
        var urlEvent = $A.get("e.force:navigateToURL");
        urlEvent.setParams({
            "url": myURL
        });
        urlEvent.fire();                          
    },

                    

1 Answer 1

0

your issue is that the anchor tags is missing the href attribute, which is what is used on right click > open in new tab to identify what url to reference.

You will have to use NavigationMixin.GenerateUrl to populate the href attribute with the appropriate url.

1
  • Thank you. href attribute resolved it.
    – SGV
    Oct 18, 2021 at 21:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.