web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Open external URL in a...
Power Pages
Unanswered

Open external URL in a new page

(0) ShareShare
ReportReport
Posted on 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:
I have the same question (0)
  • ragavanrajan Profile Picture
    7,044 Most Valuable Professional on at

    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.

  • Community Power Platform Member Profile Picture
    on at

    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

  • Fubar Profile Picture
    8,437 Super User 2025 Season 2 on at

    @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 at

    Hi,

     

    Yes, i've hyperlinked some text i have typed

  • Fubar Profile Picture
    8,437 Super User 2025 Season 2 on at

    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.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 87 Super User 2025 Season 2

#2
Jerald Felix Profile Picture

Jerald Felix 45

#3
Lucas001 Profile Picture

Lucas001 30 Super User 2025 Season 2

Last 30 days Overall leaderboard