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
Then you will need to either:
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.
Hi,
Yes, i've hyperlinked some text i have typed
@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.
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
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
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.
Fubar
62
Super User 2025 Season 2
Lucas001
48
Super User 2025 Season 2
KevinGador
44
Super User 2025 Season 2