0

I am stuck with a wordpress plugin that requires me to enter a link via a pre-defined input field. The problem is that the resulting link opens in the same window and I need it to open in a new tab. I do not have access to the HTML to change the target attribute.

Is there any way to include syntax in the actual URL to have the link open in a new window/tab? Can I do it via CSS?

To be more specific - it's a gallery of images. So will have to implement this solution across ~15 elements. I can add a script to the page.

TJ3412
  • 1
  • 2
  • Do you have access to the javascript of the page? – Steve Nov 06 '15 at 04:38
  • About the css part, check this [question](http://stackoverflow.com/questions/17281486/use-target-blank-in-css). Since you can't update the HTML your best option would be JS. – HCN Nov 06 '15 at 04:43
  • Yes - I can add a script. Messed with that a little bit, but then every link on the page was opening in a new tab. – TJ3412 Nov 06 '15 at 04:44
  • If jQuery is okay, try this. `$("a").attr("target","_blank");`. Check if the links have a unique class or id and use that, so the other links will not be affected. Refer to this [question](http://stackoverflow.com/questions/804256/how-do-i-add-target-blank-to-a-link-within-a-specified-div) if you need a non-jQuery alternative. – HCN Nov 06 '15 at 04:54
  • That's a great solution, but jQuery isn't currently being used on the site, so I'll check out non-jQuery alternative. – TJ3412 Nov 06 '15 at 05:04

1 Answers1

1

It's not possible using css You can try javascript like this

window.open('your_page.html', '_blank');
Shaiwal Tripathi
  • 601
  • 1
  • 12
  • 32