[SalesForce] LWC Navigation Mixin not replacing current page

When i try to navigate to a webpage it's loading in a new page. I want to replace current page url with the navigation URL. It' not working with below code. can anyone tell how to replace current page????

<template>
    <button onclick={navigateToWebPage}>Click To Navigate</button>
</template>

import { LightningElement, api, track } from 'lwc';
import { NavigationMixin } from "lightning/navigation";
export default class SelectComponent extends NavigationMixin(LightningElement) {
navigateToWebPage() {
    // Navigate to a URL
    this[NavigationMixin.Navigate]({
        type: 'standard__webPage',
        attributes: {
            url: 'http://salesforce.com'
        }
    },
    true // Replaces the current page in your browser history with the URL
  );
}
}

Best Answer

//Navigate to WebPage
navigateToWebPage() {
    this[NavigationMixin.GenerateUrl]({
        type: 'standard__webPage',
        attributes: {
            url: ''
        }
    }).then(url => {
        window.open("http://salesforce.com", "_self");
    });
}
Related Topic