Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-08-2005, 09:37 PM   PM User | #1
cdc08x
New Coder

 
Join Date: Sep 2005
Location: Latina (Italy)
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
cdc08x is an unknown quantity at this point
Question target="new"

I hope this is not a problem that many people before me can have asked about but...
if I do not use javascript, is there an XHTML-compliant way to make an anchor open another window? As well known, the attribute target="new" ir target="blank" is not accepted anymore by W3C standards!
cdc08x is offline   Reply With Quote
Old 12-08-2005, 09:47 PM   PM User | #2
badg0003
New Coder

 
Join Date: Jun 2005
Location: Ottawa, Ontario
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
badg0003 is an unknown quantity at this point
You are allowed to use target="_blank", but only if you are using a Transitional or Frameset DTD. The Strict DTD will produce a validation error.
__________________
Mike Badgley,
A+ Web Creations
badg0003 is offline   Reply With Quote
Old 12-08-2005, 10:23 PM   PM User | #3
cdc08x
New Coder

 
Join Date: Sep 2005
Location: Latina (Italy)
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
cdc08x is an unknown quantity at this point
Thank you!
I'll read more about this...

Considering my first theme, that is accessibility, do you think I'd better abandon the Strict DTD compliance or keep it and use js?
cdc08x is offline   Reply With Quote
Old 12-08-2005, 10:24 PM   PM User | #4
gsnedders
Senior Coder

 
gsnedders's Avatar
 
Join Date: Jan 2004
Posts: 2,340
Thanks: 1
Thanked 7 Times in 7 Posts
gsnedders will become famous soon enough
I'd just keep it opening in the same window, let the user choose if they want it in a new window/tab.
__________________
Geoffrey Sneddon
gsnedders is offline   Reply With Quote
Old 12-09-2005, 09:52 AM   PM User | #5
Bill Posters
Senior Coder

 
Join Date: Feb 2003
Posts: 1,665
Thanks: 0
Thanked 27 Times in 25 Posts
Bill Posters will become famous soon enough
Quote:
Originally Posted by Error 404
I'd just keep it opening in the same window, let the user choose if they want it in a new window/tab.
It's not always the case that the user knows the browser well enough to know how to open links in a new window.

Fwiw, there's some worthwhile reading over at this AccessifyForum thread.
http://www.accessifyforum.com/viewtopic.php?t=4209
Bill Posters is offline   Reply With Quote
Old 12-09-2005, 11:17 AM   PM User | #6
Jan
Regular Coder

 
Join Date: Jul 2002
Location: Finland
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Jan will become famous soon enough
I've asked the same some time ago and was pointed to this excellent post:
http://www.youngpup.net/2003/popups

If you want to open a link in a new window (which in my opinion should be avoided), simply use

Code:
<a href="http://www.yourlink.com/" onclick="window.open(this.href); return false;">Your link</a>
Works like a charm.
__________________
scanactive.com

Last edited by Jan; 12-09-2005 at 12:44 PM..
Jan is offline   Reply With Quote
Old 12-09-2005, 11:51 AM   PM User | #7
Bill Posters
Senior Coder

 
Join Date: Feb 2003
Posts: 1,665
Thanks: 0
Thanked 27 Times in 25 Posts
Bill Posters will become famous soon enough
Quote:
Originally Posted by Jan
If you want to open a link in a new window (which in my opinion should be avoided), simply use

Code:
<a href="http://www.yourlink.com/" onclick="window.open(); return false;">Your link</a>
Works like a charm.
Not without a url argument in the window.open method it doesn't.

I guess you meant this…
Code:
<a href="http://www.yourlink.com/" onclick="window.open(this.href); return false;">Your link</a>
…but even then, it's not a particularly efficient approach if you have many off-site links. Unless you like making work for yourself.

God forbid we should ever have to do this for every new window link…
Quote:
Originally Posted by the linked 2003 article
Code:
<a 
  href="http://google.com/" 
  onclick="window.open(this.href, 'popupwindow', 
  'width=400,height=300,scrollbars,resizable'); 
  return false;"
>
There are a number of other reasons why, imho, that method falls short of how we should be handling this kind of thing today.

Last edited by Bill Posters; 12-09-2005 at 11:54 AM..
Bill Posters is offline   Reply With Quote
Old 12-09-2005, 11:57 AM   PM User | #8
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,292
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
Here is one way without using target="_blank" of course it requires JS but if JS is disabled the use just gets taken to the page anyways in the same window.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<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>
</head>

<body>
<a href="http://www.codingforums.com" rel="external">Coding Forums</a>
</body>
</html>
_Aerospace_Eng_ is offline   Reply With Quote
Old 12-09-2005, 12:44 PM   PM User | #9
Jan
Regular Coder

 
Join Date: Jul 2002
Location: Finland
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Jan will become famous soon enough
Quote:
Originally Posted by Bill Posters
Not without a url argument in the window.open method it doesn't.
My mistake, sorry. This is what happens when I write in a hurry. Nevertheless, I seldom use forced window links and I can imagine a method like this would be very tiresome in the long run.
__________________
scanactive.com
Jan is offline   Reply With Quote
Old 12-09-2005, 12:59 PM   PM User | #10
Bill Posters
Senior Coder

 
Join Date: Feb 2003
Posts: 1,665
Thanks: 0
Thanked 27 Times in 25 Posts
Bill Posters will become famous soon enough
Quote:
Originally Posted by _Aerospace_Eng_
<a href="http://www.codingforums.com" rel="external">Coding Forums</a>[/code]
Fine if you don't have many links to address and don't mind obtrusive js - or if not all your off-site links target new windows.
Bill Posters is offline   Reply With Quote
Old 12-09-2005, 06:17 PM   PM User | #11
HWChicago
New Coder

 
Join Date: Dec 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
HWChicago is an unknown quantity at this point
controlling window size without javascript

Hi,

I have something of a related problem. I have a link that I need to open in a new window. However, because of certain program limitations I can't use javascript. All I can do is use something on the order of _blank. Is there any way to control the size of the window that opens with this or any other html command?

thanks
HWChicago is offline   Reply With Quote
Old 12-09-2005, 07:00 PM   PM User | #12
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,292
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
No you need javascript to control the window size.
_Aerospace_Eng_ is offline   Reply With Quote
Old 12-09-2005, 07:13 PM   PM User | #13
HWChicago
New Coder

 
Join Date: Dec 2005
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
HWChicago is an unknown quantity at this point
bah humbug,

ok thanks for the heads-up, guess I can stop wasting my time on that one.

tim
HWChicago is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:38 PM.


Advertisement
Log in to turn off these ads.