I have a Lightning Data table in my LWC. It is populated with line item data from an external source through apex. I want the data table to open in a new tab when a button is clicked.

Currently it is opening a new tab with the salesforce url and gives a message "This page is not available in Lighting...". The line items are not records but just text.

I have tried the following. I don't need a specific url as its just a tab to show the data table which is populated by apex callout:

<lightning-button label="google" title="Non-primary action" onclick={handleClick} class="slds-align_absolute-center"></lightning-button>

handleClick() {
    var url = "www.google.com";
    window.open(url, "_blank");

I have also tried with _blank and _parent:

<a href="www.google.com" target="_blank">Go to Site</a>

In a browser, if you do not make it an absolute URL, it is presumed to be a relative URL. You can use either:




The former tells the browser that this is a TLD (top level domain), using the current protocol (https), while the latter also explicitly specifies that https should be used.

Also, if you need a blank tab, just ask for it:

| improve this answer | |
  • Thanks. Any ideas why with the button about:blank does not load but with the <a> tag it does – M guy Sep 2 at 14:16
  • @Mguy buttons are typically used to submit a form. They don't do navigation on their own. You could use an onclick, though, which should work. – sfdcfox Sep 2 at 14:51

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.