Angular - Webpage redirect to homepage when opening external URL

Whenever I open an external URL from my webpage, this webpage redirect to homepage. The external URL gets open in new tab but the webpage from which I am opening the external URL it redirect to homepage. I don't know why this is happening I tried all the possible but couldn't get rid of it.

xyz.html

<a (click)="goToLink('https://www.example.com/abc')">page link</a>

xyz.ts

goToLink(url: string) {

  window.open(url, "_blank");

}


2 Replies

KS Kabir Singh August 20, 2022 02:12 AM UTC

There is also not found rule in my website. If any URL which is not from the website it will redirect to not found page. You can have a look on my website https://www.indiantrain.in/, and let me know the correct way for adding external link.



RS Ragunath Sukumaran Syncfusion Team August 23, 2022 02:04 PM UTC

Hi Kabir,


Greetings from Syncfusion support,


You can use the rel='nofollow' href in the anchor tag to indicate the external link and mention the target in the anchor tag to open the link in the new tab, without going for the window.open() method, because window.open() method will refresh the current page. Please refer to the below documentation to use the rel='nofollow' href and target in the anchor tag.

https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_link_target


Please get back to us if you have any queries.


Regards,
Ragunath S

 


Loader.
Up arrow icon