SOLVED

SharePoint Online not respecting target="_blank" anymore?

%3CLINGO-SUB%20id%3D%22lingo-sub-875769%22%20slang%3D%22en-US%22%3ESharePoint%20Online%20not%20respecting%20target%3D%22_blank%22%20anymore%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-875769%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI%20have%20custom%20spfx%20webparts%20that%20have%20links%20in%20them%20which%20the%20users%20wish%20to%20be%20opened%20in%20a%20new%20tab%20when%20clicked.%20This%20was%20achieved%20using%20the%20typical%20target%3D%22blank%22%20parameter%2C%20but%20just%20over%20the%20last%20week%20SharePoint%20modern%20pages%20now%20open%20these%20links%20in%20the%20same%20tab%20(previously%20they%20were%20opening%20in%20new%20tab%20as%20expected).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20tried%20this%20with%20a%20anchors%2C%20and%20also%20using%20the%20Office%20Fabric%20Link%20component%20-%20same%20result.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnyone%20know%20why%2C%20and%20how%20I%20can%20get%20these%20links%20to%20open%20in%20a%20new%20tab%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlso%20worth%20noting%20that%20the%20links%20to%20lists%20and%20libraries%20off%20the%20Site%20Contents%20page%20still%20open%20in%20a%20new%20tab%20-%20can%20I%20replicate%20this%20behaviour%20somehow%3F%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-875769%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Efabric%20react%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESPFx%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-875858%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20not%20respecting%20target%3D%22_blank%22%20anymore%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-875858%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F42656%22%20target%3D%22_blank%22%3E%40Nigel%20Witherdin%3C%2FA%3E%26nbsp%3B%20I%20just%20tried%20and%20all%20look%20good%20for%20me.%20Make%20sure%20we%20use%26nbsp%3B%3CSPAN%3Etarget%3D%22_blank%22%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3Epublic%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Erender%3C%2FSPAN%3E%3CSPAN%3E()%3C%2FSPAN%3E%3CSPAN%3E%3A%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Evoid%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Ethis%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3EdomElement%3C%2FSPAN%3E%3CSPAN%3E.%3C%2FSPAN%3E%3CSPAN%3EinnerHTML%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%3D%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3E%60%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nb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ERe%3A%20SharePoint%20Online%20not%20respecting%20target%3D%22_blank%22%20anymore%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-875860%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394813%22%20target%3D%22_blank%22%3E%40Vikram_Samal%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%20strange%20-%20I%20am%20using%3A%3C%2FP%3E%3CPRE%3E%3CDIV%20class%3D%22ms-TooltipHost%20root-449%22%3E%3CBR%20%2F%3E%3CA%20target%3D%22_blank%22%20href%3D%22https%3A%2F%2Fscentregroup.sharepoint.com%2Fsites%2Fhrrefresh%22%20class%3D%22ms-Link%20root-592%22%20style%3D%22font-size%3A%2017px%3B%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EHR%3C%2FA%3E%3CBR%20%2F%3E%26lt%3B%2Fdiv%26gt%3B%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20clicking%20the%20link%20is%20opening%20in%20the%20current%20tab.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20furthermore%2C%20the%20out%20of%20the%20box%20%22News%22%20webpart%20is%20opening%20clicked%20articles%20in%20the%20same%20window%20even%20though%20they%20have%20the%20target%3D%22_blank%22%3A%3C%2FP%3E%3CPRE%3E%26lt%3Ba%20aria-label%3D%22Operating%20Capital%20Approvals%20launch%20Published%20by%20Nigel%20Witherdin%20on%2027%20June.%20Description%3A%20Lorem%20ipsum%20dolor%20sit%20amet%2C%20consectetur%20adipiscing%20elit.%20Phasellus%20ut%20viverra%20nunc.%20Sed%20tempus%20accumsan%20mi%2C%20vitae%20ultricies%20urna%20vulputate%20sit%20amet.%20Donec%20non%20molestie%20nisl%2C%20a%20ornare%20ipsum.%20Quisque%20id%20tristique%20neque.%20Nunc%20imperdiet%20felis%20nulla%2C%20nec%E2%80%A6%22%20data-automation-id%3D%22newsItemTitle%22%20href%3D%22https%3A%2F%2Fscentregroup.sharepoint.com%2Fsites%2Ftechnologyrefresh%2FSitePages%2FOperating-Capital-Approvals-launch.aspx%22%20target%3D%22_blank%22%20data-interception%3D%22propagate%22%20class%3D%22text_title_d116a82a%20text_title-228%20textListLayoutTitle_d116a82a%22%20tabindex%3D%22-1%22%26gt%3BOperating%20Capital%20Approvals%20launch%26lt%3B%2Fa%26gt%3B%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMaybe%20something%20else%20in%20my%20code%20base%20is%20affecting%20something%3F%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-875867%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20not%20respecting%20target%3D%22_blank%22%20anymore%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-875867%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F42656%22%20target%3D%22_blank%22%3E%40Nigel%20Witherdin%3C%2FA%3E%26nbsp%3BI%20stipped%20down%20all%20styling%20and%20tried%20still%20the%20same%20and%20opening%20in%20new%20tab.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%20%20public%20render()%3A%20void%20%7B%0A%20%20%20%20this.domElement.innerHTML%20%3D%20%60%0A%20%20%20%20%20%20%3CDIV%3E%0A%20%20%20%20%20%20%20%20%3CA%20target%3D%22_blank%22%20href%3D%22%26lt%3Ba%20href%3D%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EClick%22%20target%3D%22_blank%22%26gt%3Bhttps%3A%2F%2Faka.ms%2Fspfx%22%26gt%3BClick%3C%2FA%3E%20Here%0A%20%20%20%20%20%20%3C%2FDIV%3E%60%3B%0A%20%20%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ECan%20you%20try%20with%20the%20different%26nbsp%3Bbrowser%20just%20to%20ensure%20no%20other%20issue.%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-875892%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20not%20respecting%20target%3D%22_blank%22%20anymore%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-875892%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394813%22%20target%3D%22_blank%22%3E%40Vikram_Samal%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIts%20happening%20in%20both%20IE%20and%20Chrome%2C%20and%20it%20is%20occurring%20on%20other%20sites%20in%20our%20tenancy%20(so%20not%20related%20to%20our%20custom%20code%20I%20guess).%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20might%20have%20to%20involve%20Microsoft%20directly%20I%20guess....%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-877323%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20not%20respecting%20target%3D%22_blank%22%20anymore%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-877323%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F42656%22%20target%3D%22_blank%22%3E%40Nigel%20Witherdin%3C%2FA%3E%26nbsp%3Byou%20need%26nbsp%3B%3CSPAN%20class%3D%22crayon-e%20%22%3Edata-interception%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-o%22%3E%3D%3C%2FSPAN%3E%3CSPAN%20class%3D%22crayon-s%20%22%3E%22off%22%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20a%20very%20detailed%20post%20explaining%20the%20issue%3A%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fjulieturner.net%2F2018%2F08%2Fspfx-anchor-tags-hitting-the-target%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fjulieturner.net%2F2018%2F08%2Fspfx-anchor-tags-hitting-the-target%2F%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20this%20helps%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-878039%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Online%20not%20respecting%20target%3D%22_blank%22%20anymore%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-878039%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F9907%22%20target%3D%22_blank%22%3E%40Joel%20Rodrigues%3C%2FA%3E%26nbsp%3B-%20Nailed%20it!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20so%20much%20-%20adding%20the%20tag%20in%20resolved%20the%20issue%2C%20with%20the%20bonus%20that%20it%20doesnt%20really%20seem%20to%20add%20any%20extra%20processing%20time%20as%20Julie%20warns%20about%20in%20her%20post.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20again!%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Contributor

Hi,

I have custom spfx webparts that have links in them which the users wish to be opened in a new tab when clicked. This was achieved using the typical target="blank" parameter, but just over the last week SharePoint modern pages now open these links in the same tab (previously they were opening in new tab as expected).

 

I have tried this with a anchors, and also using the Office Fabric Link component - same result.

 

Anyone know why, and how I can get these links to open in a new tab?

 

Also worth noting that the links to lists and libraries off the Site Contents page still open in a new tab - can I replicate this behaviour somehow??

 

Thanks!

 

6 Replies
Highlighted

@Nigel Witherdin  I just tried and all look good for me. Make sure we use target="_blank"

 

public render(): void {
    this.domElement.innerHTML = `
      <div class="${ styles.helloWorld }">
        <a href="https://aka.ms/spfx" class="${ styles.title }" target="_blank">Click Here</a>
      </div>`;
  }
Highlighted

@Vikram_Samal 

 

So strange - I am using:

<div class="ms-TooltipHost root-449">
<a target="_blank" href="https://scentregroup.sharepoint.com/sites/hrrefresh" class="ms-Link root-592" style="font-size: 17px;">HR</a>
</div>

 

and clicking the link is opening in the current tab.

 

And furthermore, the out of the box "News" webpart is opening clicked articles in the same window even though they have the target="_blank":

<a aria-label="Operating Capital Approvals launch Published by Nigel Witherdin on 27 June. Description: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ut viverra nunc. Sed tempus accumsan mi, vitae ultricies urna vulputate sit amet. Donec non molestie nisl, a ornare ipsum. Quisque id tristique neque. Nunc imperdiet felis nulla, nec…" data-automation-id="newsItemTitle" href="https://scentregroup.sharepoint.com/sites/technologyrefresh/SitePages/Operating-Capital-Approvals-launch.aspx" target="_blank" data-interception="propagate" class="text_title_d116a82a text_title-228 textListLayoutTitle_d116a82a" tabindex="-1">Operating Capital Approvals launch</a>

 

Maybe something else in my code base is affecting something??

 

 
Highlighted

@Nigel Witherdin I stipped down all styling and tried still the same and opening in new tab. 

 

 

 

 

  public render(): void {
    this.domElement.innerHTML = `
      <div>
        <a target="_blank" href="<a href="https://aka.ms/spfx">Click" target="_blank">https://aka.ms/spfx">Click</a> Here</a>
      </div>`;
  }

 

 

 
Can you try with the different browser just to ensure no other issue.
Highlighted

@Vikram_Samal 

 

Its happening in both IE and Chrome, and it is occurring on other sites in our tenancy (so not related to our custom code I guess).

 

I might have to involve Microsoft directly I guess....

Highlighted
Best Response confirmed by Nigel Witherdin (Contributor)
Solution

@Nigel Witherdin you need data-interception="off"

 

This is a very detailed post explaining the issue:

https://julieturner.net/2018/08/spfx-anchor-tags-hitting-the-target/

 

Hope this helps

Highlighted

@Joel Rodrigues - Nailed it!

 

Thank you so much - adding the tag in resolved the issue, with the bonus that it doesnt really seem to add any extra processing time as Julie warns about in her post.

 

Thanks again!