link target handling at the wiki plugin

Discussion corner for Developers of Serendipity.
Post Reply
SEA
Posts: 1
Joined: Sat Jul 14, 2007 10:44 am

link target handling at the wiki plugin

Post by SEA »

Hello Developers ;-)

Code: Select all

if ($target) {
      // use a "popup" window.  this is XHTML compliant, suggested by
      // Aaron Kalin.  uses the $target as the new window name.
      $target = htmlspecialchars($target);
      $output .= " onclick=\"window.open(this.href, '$target');";
      $output .= " return false;\"";
}
This are some lines of "serendipity/bundled-libs/Text/Wiki/Render/Xhtml/Url.php" (line 70) which belongs to the text-wiki plugin. They add a short onclick attribute to wiki links which opens the url in a new frame.

So my question are:
1. Why do you use java script instead of target="_blank"?
2. What do you think about <base target="_blank">?
It's a part of HTML 3.2 (XHTML 1.0) and is supported by many browsers (Netscape 3.0, IE 3.0, FF 1.0, ...).
So if the wiki parser put the base-tag around it's text the user also can add an own base-tag into the wiki text so the autor can decide by himself to open links in "_self". This is very usefull for links to own blog-entries or static pages.

I hope you understand me ;-)

bye
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: link target handling at the wiki plugin

Post by garvinhicking »

Hi!

First off, your questions are related to the PEAR Wiki package. Serendipity just bundles it, we are not the authors.
1. Why do you use java script instead of target="_blank"?
target="_blank" is not XHTML valid.
2. What do you think about <base target="_blank">?
That would be REALLY bad, because also internal links would then open in a new window. This would spam the users with new windows. <base...> is relevant for all links of a document.

If you really like the 'base target' thing, you could add it to your templates index.tpl file, though.

Popup windows suck. The user agent should decide how to open new links. If a user wants a new window, he can use his middle mouse click, or whatever the browser offers him. This is much better usability, and also the reason why 'target' was kicked frmo the XHTML (Strict) specification.

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply