1 (edited by rADo 2004-06-27 11:23)

Topic: open links in new window while being XHTML 1.0 STRICT valid

now, I use this code to open new windows, while still staying XHTML 1.0 STRICT valid, and maintaining accesibility even with JavaScript switched-off, or with pop-up blockers:

<script type='text/javascript'> 
<!--
function openwin(url) {
  if( window.open(url,'','left=0,top=0,scrollbars=yes,location=no,resizable=yes') ) 
    return false; 
  else 
    return true;
}
// -->
</script>

now, instead of target="_blank" you will use onclick="return openwin(this.href)"

Example?

<a href="..." onclick="return openwin(this.href)">Website</a>

Simple, easy to do, and fully accesible and valid... smile

Re: open links in new window while being XHTML 1.0 STRICT valid

Why not just:

<a href="..." onclick="return window.open(this.href, '')">Website</a>

Not sure the name attribute is mandatory though. I've seen both.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

3 (edited by rADo 2004-06-27 14:36)

Re: open links in new window while being XHTML 1.0 STRICT valid

well, simply because if window.open() will fail (in case there is a popup blocker), not JAvaScript, neither href="" will open the window wink

this would be ok:

<a href="..." onclick="return !window.open(this.href, '')">Website</a>

but.. it is always preferable to use a function..

Re: open links in new window while being XHTML 1.0 STRICT valid

Ah, I see. I figured the function returned a boolean, but now I see it ruturns a handle to the new window.

We've discussed the opening of links in new windows before. I leaning towards opening all links in the same window and thereby putting the control in the hands of the user.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

5 (edited by rADo 2004-06-27 14:46)

Re: open links in new window while being XHTML 1.0 STRICT valid

Rickard wrote:

We've discussed the opening of links in new windows before. I leaning towards opening all links in the same window and thereby putting the control in the hands of the user.

I have the same opinion, but, since you provide option to set this in user profile, I open new windows only when user wishes so in his/her profile.

The thing is, you might want to think about changing the default behaviour (links in new windows ON)

6 (edited by Paul 2004-06-27 15:30)

Re: open links in new window while being XHTML 1.0 STRICT valid

Or you could go to XHTML 1.1 in which case you can theoretically use the target attribute module via your own DTD. But then you run into the problem of the style attribute being deprecated. I feel an experiment coming on.

More generally, my main concern is the help system. You can for example read the bbcode help whilst completing your post if you tile your windows. You could probably achieve greater functionality by having bbcode help etc in a div above/below the post box which has it's display setting toggled on and off. That can be done with php server side style switching. Actully its pathetically simple, same method as colour striping in viewtopic.php.

I must admit, I have never given a second though to what to do about links in posts. That could be because I always right click and open new window anyway.