Skip to main content
Community site session details

Community site session details

Session Id : 7A/ZRU8nA6o33sU31uERmr
Power Pages - General Discussions
Unanswered

Open external URL in a new page

Like (0) ShareShare
ReportReport
Posted on 14 Mar 2023 06:26:23 by

Hi all,

 

I have a Power Page site, and in one of the text fields, i have hyperlinked a url to an external website. However when i click on it, it opens on the page i'm on(the Power Pages site) instead of opening a completely new tab.

 

How can i ensure that everytime a user clicks on the url, that a new tab opens? 

 

Thanks

Categories:
  • Fubar Profile Picture
    8,056 Super User 2025 Season 2 on 15 Mar 2023 at 02:41:16
    Re: Open external URL in a new page

    Then you will need to either:

    • Find the anchor <a href=> tag for it  and add target="_blank", or
    • Hijack the on click of the link (which is Raga's last bit of code)

    The issue with hijacking the click is as they don't put an id in the <a> tag, and so if you just do "a" then if you have other links that you need to open in the same tab they will also open in a new tab.

     

    As I mentioned, you can manually update the code etc you just need to do it from the Portal Management app on the localized version of the Web Page.

  • Community Power Platform Member Profile Picture
    on 15 Mar 2023 at 01:42:04
    Re: Open external URL in a new page

    Hi,

     

    Yes, i've hyperlinked some text i have typed

  • Fubar Profile Picture
    8,056 Super User 2025 Season 2 on 15 Mar 2023 at 01:34:28
    Re: Open external URL in a new page

    @Anonymous wrote:

    i have hyperlinked a url to an external website. However when i click on it, it opens on the page i'm on(the Power Pages site) instead of opening a completely new tab.

     

     


    Provide some details of how you hyper linked it (screen shot would also help), have you just hyperlinked some text content you have typed or is it actually the content from a dataverse record (e.g. it is a data field on a form).

     

    For PowerPages all the edit code is really doing is using VS Code to update the Page Copy, Custom JavaScript, and Custom CSS fields on the Web Pages localized content page.  If you are unable to use VS Code etc you can edit this manually via the Portal Management App, and opening the respective Web Page record and then opening its localized page from its the subgrid.

  • Community Power Platform Member Profile Picture
    on 15 Mar 2023 at 00:52:09
    Re: Open external URL in a new page

    Thanks for the response!

     

    I'm trying the 2nd method but i think it's because my link/external link is in the 'text' portion before the form.

     

    Is there a way to do this for texts? Unfortunately i can't access VS Code at the moment

  • ragavanrajan Profile Picture
    7,036 Most Valuable Professional on 14 Mar 2023 at 10:59:58
    Re: Open external URL in a new page

    Hi @Anonymous ,

     

    There are two ways to achieve it. 

    1. Using HTML anchor tag target attribute 

    2. Using Javascript to open it in new tab 

     

    Method 1: Using HTML Anchor tag 

     

    In Design studio: 

     

    1. Edit the page > Text field > Click Edit Code 

     

    ragavanrajan_0-1678791159828.png

     

    2. In the VSCODE > Add the following HTML code to open your external URL in the new tab 

     

     <h1 style="color: var(--portalThemeColor4);"><a href="https://www.google.com/" target="_blank" rel="noopener noreferrer">​<b aria-label="Text Click here to open hyperlink in new tab Press enter to edit" style="position: relative;">Click here to open hyperlink in new tab</b></a></h1>

     

    Note:  The above code target =_blank and rel is important to avoid phishing attacks and open in the new tab. 

     

    Hit save and Sync > preview the website 

     

    Method 2: Assuming you are using forms 

     

    In Portal management 

     

    1 .Under Content > Basic Forms > Additional Settings > Custom Javascript 

    2. Add the following jquery and hit save and close 

    3.

    $(document).on('click', 'a', function(e){ 
     e.preventDefault(); 
     var url = $(this).attr('href'); 
     window.open(https://www.google.com/, '_blank');
    });

     

     

    Have fun. 

     

    Hope it helps. 
    ------------

    If you like this post, give it a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users to find it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 62 Super User 2025 Season 2

#2
Lucas001 Profile Picture

Lucas001 48 Super User 2025 Season 2

#3
KevinGador Profile Picture

KevinGador 44 Super User 2025 Season 2