Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2013-08-31 15:09:01

PAVANE-Design
New Member
Registered: 2013-08-31
Posts: 2

Opening URL in new window

Hi there! :)

Does anyone of you know how I can make a link in an article open in a new window (target blank)? I’m not sure whether it’s possible to customise the (name):“URL” attribute. ;)

Thank you for any comments.

Offline

#2 2013-08-31 15:57:38

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Opening URL in new window

In article body content, you can either use normal HTML:

<a href="http://example.com" target="_blank">text</a>
In Textile you have to use a class and JavaScript. E.g.
"(extenal)text":http://example.com

Which generates:

<p><a class="external" href="http://example.com">text</a></p>

You can then attach an event handler to the external class, which on click event opens the link in a new window:

$('a.external').on('click', function (e)
{
    e.preventDefault();
    window.open($(this).attr('href'));
});

Relies on jQuery library.

Offline

#3 2013-09-01 11:03:20

PAVANE-Design
New Member
Registered: 2013-08-31
Posts: 2

Re: Opening URL in new window

Oh, I see! That should indeed work; thanks for your clearance.

Offline

Board footer

Powered by FluxBB