I have a webpart on a site that allows you to insert a "Show more" link to an external page that expands on the information displayed in the webpart. Unfortunately this option only takes a regular URL as the value for the link, it doesn't let you construct the HTML link itself. I need this link to open in a new tab but since I only get to put the URL in, I can't use the normal target="_blank"
HTML code. Is there a way to craft the URL itself to force a new tab?
Asked
Active
Viewed 2,028 times
1

thanby
- 323
- 1
- 6
- 22
-
Can you use javascript or jquery ? – Pedro Lobito Oct 11 '15 at 17:56
-
No. You'll need to be able to modify or add some code. – azium Oct 11 '15 at 17:56
2 Answers
4
In javascript:
window.open("url");
Or adding the attr:
document.getElementById("theLink").setAttribute("target", "_blank");
With the following html
<a id="theLink" href="url">

Marcos Pérez Gude
- 21,869
- 4
- 38
- 69
1
If you cannot modify any part the a
tag, you can use jquery
.
The following script will try to open all links on a different tab/window:
$("a").on("click",function(){
event.preventDefault();
window.open($(this).attr('href'),'_blank');
});
NOTE:
Make sure you read this answer

Community
- 1
- 1

Pedro Lobito
- 94,083
- 31
- 258
- 268