cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Automation Master
Automation Master

Forms - is it possible to have an hyperlink field that opens in new tab?

Hi,

I'm using Nintex Forms 2016 and I'm wondering if there is an easy way to make an hyperlink field (tied to a sharepoint column) in display mode to open the URL in a new tab instead of the current one..

Do you have any suggestion? Or should I use javascript in order to add a target="_blank" or similar to the <a> tag?

thanks

Giacomo

0 Kudos
Reply
8 Replies
Automation Master
Automation Master

Re: Forms - is it possible to have an hyperlink field that opens in new tab?

0 Kudos
Reply
Automation Master
Automation Master

Re: Forms - is it possible to have an hyperlink field that opens in new tab?

Hi ‌, thanks for the suggestion (do you ever sleep? you answer question all the time! ) but I don't think it's applicable to my scenario..

I'm using the standard hyperlink control because I have to show the link that is set in that specific column (with URL and description, so it should show the description and link to the URL) and that column is updated by a workflow..

Reply
Automation Master
Automation Master

Re: Forms - is it possible to have an hyperlink field that opens in new tab?

Haha why sleep when you can be on the community! No just kidding. Only jumped in with that as I was so amazed by what ‌ posted on that thread I need to share it (and thought it might help)! 

Reply
Automation Master
Automation Master

Re: Forms - is it possible to have an hyperlink field that opens in new tab?

do you have control over what link is written to the list field in workflow?

if so, you could inject 'target' attribute into link there.

Reply
Automation Master
Automation Master

Re: Forms - is it possible to have an hyperlink field that opens in new tab?

not for what I know..SharePoint hyperlink field is composed by two subfields, one for URL and one for description..no place on how it's rendered..

Reply
Automation Master
Automation Master

Re: Forms - is it possible to have an hyperlink field that opens in new tab?

OK.

so, I haven't realized first it's sharepoint hyperlink field. you are right, this filed doesn't allow to customize link attributes OOTB .

my other idea was a link in a form 'javascript:window.open('URL');' might be a way to go (which is by specification valid href entry).

but unfortunately after some tests I found out, that sharepoint tries to be super-intelligent and changes provided URL string to something what it thinks the URL should look like. so it eg. prepends protocol specifier (http://, file:// ...) or site URL, etc.

all that (quite significantly) restricts usability of hyperlink-type field.

so if you are stick to use hyperlink-type field, you will likely need to customize link's attributes at client side (javascript).

if you still have chance to change field's datatype, I would suggest to make it numeric field and build whole link definition (html element)  on your own.

with such a setup and Oldest SharePoint trick ever () described by Ryan Greenaway‌ you could IMHO achieve the same functionality.

Reply
sledresseur
Nintex Newbie

Re: Forms - is it possible to have an hyperlink field that opens in new tab?

Hi all,

I faced similar need with link inside a label for a "I agree terms and conditions" checkbox.

My work around was using javascript as following:

1° add a css class name to my label (ex: lblLink)

2° in form setting / custom javascript, add the following javascript:

    NWF.FormFiller.Events.RegisterAfterReady(function(){
        NWF$(".lblLink a").attr("target", "_blank");
    });
In my case, I set css class as we can't save control ID in javascript variable for label controls, in your case as you're using hyperlink control, you can save control client ID and then code would look like
       NWF$("#" + varCtrlClientID + " a").attr("target", "_blank");
If you don't need to set the attribut on a specific <a> you can also simply write
       NWF$("a").attr("target", "_blank");
in that case any link in the form will open in a new tab.
Reply
chaddavis
Nintex Newbie

Re: Forms - is it possible to have an hyperlink field that opens in new tab?

I realize this is an older post, but I stumbled across it while trying to do the same thing so, I thought I'd add my two cents.

I didn't want to apply this rule to all <a> tags, but I did want to add it to all hyperlink fields on the form. 

As you've all discovered, it seems custom CSS classes and JavaScript variables set in the form controls don't get set when the form is in display mode (which is very unfortunate).

I decided to look for some other unique-ish identifier, and came across the 

data-formcontroltypeid="a0c89d70-0781-4bd4-8623-a73675005a05"

Now, I have no idea if this is the same for everyone else out there (please comment if it is or isn't), but it is the same for me even across different site collections. So, I felt this would work well for me.

I then used this line of code and it's working perfectly:

NWF$("div[data-formcontroltypeid='a0c89d70-0781-4bd4-8623-a73675005a05'] a").prop('target','_blank');

The code finds all <div> objects with that specific 'data-formcontroltypeid'.

Then it finds all <a> objects inside the <div> objects.

Lastly, it applies the target property set to '_blank' to the <a> object.

And actually, in my case, I took it a step further since I know this will only be needed when in Display Mode:

var isDisplayMode = document.location.pathname.indexOf("/DispForm.aspx") > -1;
if (isDisplayMode) NWF$("div[data-formcontroltypeid='a0c89d70-0781-4bd4-8623-a73675005a05'] a").prop('target','_blank');
0 Kudos
Reply