Topic: XHTML Strict 1.0 and "target"

Hi

I was thinking about links. You're using XHTML strict but how do you get links to open in the same window and not in a new one(_blank) that is standard?

I usually go with transitional just to be able to use the HTML attribute "target".

Or is it only my browser(FF) that has got _blank as default?

///
Christoffer "Holmen" Holmstedt

2

Re: XHTML Strict 1.0 and "target"

_blank is not standard.

But if you want to be sure use target="_self"

The German PunBB Site:
PunBB-forum.de

Re: XHTML Strict 1.0 and "target"

you should never open links in new windows, the only reason is for help boxes or whatnot when you can use javascript

4

Re: XHTML Strict 1.0 and "target"

The target attribute is not valid XHTML 1.0 Strict regardless of what form it takes. PunBB does not use the target attribute anywhere. The only links that should open in a new window are the help links which are controlled by javascript.

The normal behaviour of a browser including Firefox is to open links in the same window. If you are getting links opening in a new window then check the options settings.

5

Re: XHTML Strict 1.0 and "target"

Well,

I guess the "Should links open in a new window or not" discussion  is a rather religious one.
I like it if links I click on in a discussion board open somewhere else so I don't have to jump back and forth all the time.
Actually my users complained about links opening in the same window....
But of course I personally don't use "_blank", just  click on links using the middle mouse key and told Firefox to open those in a new tab smile

The German PunBB Site:
PunBB-forum.de

Re: XHTML Strict 1.0 and "target"

Paul wrote:

The target attribute is not valid XHTML 1.0 Strict regardless of what form it takes. PunBB does not use the target attribute anywhere. The only links that should open in a new window are the help links which are controlled by javascript.

The normal behaviour of a browser including Firefox is to open links in the same window. If you are getting links opening in a new window then check the options settings.

Ok, thanks.
I'll start working with XHTML strict.

Re: XHTML Strict 1.0 and "target"

Tobi wrote:

But if you want to be sure use target="_self"

Yes, that is what I've been using and that's the reason for not been able to use XHTML strict.
The target attribute is only valid in transitional.

8

Re: XHTML Strict 1.0 and "target"

Just out of curiosity:
Is there no way to open a link in a new window using XHTML strict?

And if so: Why not?
I mean, is there any browser that wouldn't support the target attribute?
And is there really no use to open a link in a new window from time to time?
And if there is wouldn't it be better then to use XHTMl transitional anyway?

The German PunBB Site:
PunBB-forum.de

9

Re: XHTML Strict 1.0 and "target"

The reason is that XHTML is a markup language. Its function is to take content and wrap it in the appropriate tags to give the content a semantic meaning. That is all it is for. That is all html was for, it just got stretched way beyond its orginal function. The styling of content is the job of css. Browser behaviour is the job of a scripting language like javascript.

As for opening links in a new window, I surf like that all the time. The point is the links open in a new window because I choose to make them work like that not because the designer forced it on me. Incidentally, it not just XHTML, HTML 4.01 Strict doesn't allow the target attribute either.

10

Re: XHTML Strict 1.0 and "target"

The solution would be in user profile if he wants to choose external links = new window.

I'm not ok with this system which has as philosophy = click and click and click and of course, to come back ... back button and back button and back button : if for you it's great, why not. But for "normal" users, it's not happiness.

Sometimes standards have to be forced : it's like this IFRAME or INNERHTML have become standards (but they were born inside IE only, at 1998)

Re: XHTML Strict 1.0 and "target"

not this again, we've had this discussion before sad

12 (edited by Rod 2005-07-08 16:18)

Re: XHTML Strict 1.0 and "target"

To answer Tobi : to create NEW WINDOW despite XHTML 1.0 strict, here's a script I have found on dynamicdrive

<script type="text/javascript">
         <!--
    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;
           -->
        </script>

Any link you want a new window, add rel=external in A attribute

<a href="http://www.sortons.net" rel="external">Sortons.Net</a>

After, in parser.php

'#\[winurl\](.*?)\[/winurl\]#',
'#\[winurl=(.*?)\](.*?)\[/winurl\]#',

'<a href="$1" rel="external">$1</a>',
'<a href="$1" rel="external">$2</a>',

When you'll apply in your code [winurl]yoururl.com[/winurl] it adds the rel="external" inside your A HREF attribute ... and with the script, it open in a new window.

13

Re: XHTML Strict 1.0 and "target"

Thanks,

so this is a workaround to play the XHTML strict game, right?

Wow.... quite a lot of code to replace [i]target="_blank"[i].

I still think it is better to stay with transitional then.
I changed my board to target="_blank" and it works fine.... I think sometimes rules that are set up to simplify things just reach the opposite...like in this case. wink

The German PunBB Site:
PunBB-forum.de

14

Re: XHTML Strict 1.0 and "target"

Tobi wrote:

Thanks,

so this is a workaround to play the XHTML strict game, right?

Wow.... quite a lot of code to replace [i]target="_blank"[i].

I still think it is better to stay with transitional then.
I changed my board to target="_blank" and it works fine.... I think sometimes rules that are set up to simplify things just reach the opposite...like in this case. wink

Here's another, much simpler way of making this work smile This little mod will open local URL's in the same window, but external URL's will open in a new one.

Open include/parser.php.

Around line 278, find:

return '<a href="'.$full_url.'">'.$link.'</a>';

Replace with:

    if (strpos($full_url, $_SERVER["SERVER_NAME"]) === FALSE)
        return '<a href="'.$full_url.'" onclick="window.open(this.href); return false;">'.$link.'</a>';
    else
        return '<a href="'.$full_url.'">'.$link.'</a>';

What this does, is look for your server name in the URL. If it can't find it, it'll add the javascript needed to open a new window smile

15

Re: XHTML Strict 1.0 and "target"

Indeed smile

16

Re: XHTML Strict 1.0 and "target"

CodeXP wrote:

Here's another, much simpler way of making this work smile

Yeah, that is much easier. It can be turned into a mod as well so that the admin can set if external urls are to be opened in a new window or not.
Nice, thanks.

The German PunBB Site:
PunBB-forum.de

17

Re: XHTML Strict 1.0 and "target"

Actually a checkbox "New windiw links" In a bottom of a topicview (for example) with javascript restorable state, which will change "click action" way of new link opening, in the same window, or in new one. People will be having much more flexible and fast customization.