Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2006-02-25 18:04:30
- tez
- Member
- Registered: 2006-02-25
- Posts: 22
(Beginner) Open links in new window?
Hi
Just a quick query about the zem_prblock plugin.
I’ve just installed it and I’d like to use it initially just to add target=”_blank” to all external links in an article body.
When I wrote a test article I couldn’t get it to work. I thought it would appear as an option when you are drafting new articles.
So, I then went to the forms tab and changed my default article from:
<code><h3><txp:permlink><txp:title /></txp:permlink> · <txp:posted /> by <txp:author /></h3>
<txp:body />
<txp:comments_invite wraptag=“p” />
<div align=“center”><img src=”<txp:site_url />images/1.gif” style=“height:1px;width:400px” class=“divider” alt=”“ /></div></code>
to:
<code><h3><txp:permlink><txp:title /></txp:permlink> · <txp:posted /> by <txp:author /></h3>
<txp:zem_prblock target=”_blank”>
<txp:body />
</txp:zem_prblock>
<txp:comments_invite wraptag=“p” />
<div align=“center”><img src=”<txp:site_url />images/1.gif” style=“height:1px;width:400px” class=“divider” alt=”“ /></div></code>
But again, no joy.
So, for good measure I changed my Links form from
<code><p><txp:link /><br />
<txp:link_description /></p></code>
to:
<code><txp:zem_prblock target=”_blank”>
<p><txp:link /><br />
<txp:link_description /></p>
</txp:zem_prblock></code>
but once again…no joy!
I hope that’s clear and you can help.
Thanks
tez
Offline
#2 2006-02-25 23:32:14
- NyteOwl
- Member
- From: Nova Scotia, Canada
- Registered: 2005-09-24
- Posts: 539
Re: (Beginner) Open links in new window?
Just a small fyi; target is a long deprecated attribute and it’s use generally considered bad form. It will break the valid x/html+css of your pages. If you insist on this type of page behaviour it would be more standards compliant to open the new window(s) via javascript.
Obsolescence is just a lack of imagination. / 36-bits Forever! / #include <disclaimer.h>;
Offline
#3 2006-02-26 09:39:57
- tez
- Member
- Registered: 2006-02-25
- Posts: 22
Re: (Beginner) Open links in new window?
Thanks for that!
Tez
Offline
Re: (Beginner) Open links in new window?
Tez – take a look at http://www.agmckee.co.uk/academy/advanced/replacement-for-targetblank
for some advice on how to open new windows with JavaScript and mark them with a image to show they will do this. It’s a more accessible method, and if the javascript isn’t present the link works as normal.
Last edited by Alex McKee (2006-02-26 12:13:53)
Offline
#5 2006-02-26 12:22:47
- tez
- Member
- Registered: 2006-02-25
- Posts: 22
Re: (Beginner) Open links in new window?
Hi Alex
Many thanks for the link…much appreciated!
Tez
Offline
Re: (Beginner) Open links in new window?
You’re welcome. Any probs, just e-mail me.
Offline
#7 2006-02-26 13:50:46
- alexandra
- Member
- From: Cologne, Germany
- Registered: 2004-04-02
- Posts: 1,370
Re: (Beginner) Open links in new window?
Zem did adress your question in the FAQ
hope it helps.
Last edited by alexandra (2006-02-26 13:51:03)
Offline
#8 2006-02-26 15:12:15
- tez
- Member
- Registered: 2006-02-25
- Posts: 22
Re: (Beginner) Open links in new window?
Hi Alexandra
Yes, it all helps…
Many thanks!
Tez
Offline
Re: (Beginner) Open links in new window?
Great, I didn’t know about Zem’s plugin. That’s awesome, I can now fully integrate my linkage with TXP.
Superb!
Alex
Offline
Re: (Beginner) Open links in new window?
Alex Mckee, or Alexandra,
I have a need for a rel=“external” links on a client’s site, and I have followed all the instructions above, but find that I am not getting the expected results.
here is the page I am working on
This is an example of the links being generated by zem_prblock:
<code>
<a href=“http://www.fincalc.com/BUD_05.asp?id=16029” rel=“external”>How long will my money last with systematic withdrawals?</a>
</code>
Here is my javascript:
<code>
function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName(“a”);
for (var i=0; i<anchors.length; i++) {
var anchor = anchors[i];
if (anchor.getAttribute(“href”) &&
anchor.getAttribute(“rel”) == “external”)
anchor.target = “_blank”;
}
}
window.onload = externalLinks;
</code>
So, what’s the problem? Hmm.
EDIT: I hadn’t put the script in the right location of the site (as I was only applying it to one section
However, I do have a new question? How would one add a width in pixels to size the new window?
Thanks,
Matthew
Last edited by ma_smith (2006-03-17 03:54:26)
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline
Re: (Beginner) Open links in new window?
OK, so I have a question that sorta begs for a Textile update.
My clients want simplicity. My clients don’t know code from Adam. I’ve had a hard enough time teaching them to use Textile. When they enter links in Textile, I need for their links to open externally with valid XHTML code. I’ve been using the aforementioned DOM script approach for a little while now.
But, even using the DOM script, there’s still no way to insert rel=“external” into a link using Textile. I’ve tried it inline and using the alias method and neither works.
This tiny little problem, all by itself, might force me to abandon Textpattern for several projects in development.
Any help on this would be greatly appreciated…
Offline
Pages: 1