473,796 Members | 2,679 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

target="_blank" ... but better ?

Hi,

I've used an excellent way to make target="_blank" links that still
validate while using HTML 4.01 Transitional doctypes in the past.

I learned the trick from : http://www.sitepoint.com/article/1041

Basically, instead of typing :
<a href="yourlink. html" target="_blank" alt="">The link</a>

You type :
<a href="yourlink. html" class="external " alt="">The link</a>

And it's the same due to this little piece of javascript :

/* Evite de mettre des target="_blank" */
function externalLinks() {
if (!document.getE lementsByTagNam e) return;
var anchors = document.getEle mentsByTagName( "a");
for (var i=0; i<anchors.lengt h; i++) {
var anchor = anchors[i];
if (anchor.getAttr ibute("href") &&
anchor.getAttri bute("class") == "external")
anchor.target = "_blank";
}
}
window.onload = externalLinks;

Now, eventhough this perfectly works, I wish I could do a little
something more (with your help).

What I would like to archieve would be the following :

When typing :
<a href="yourlink. html" class="external " alt="">The link</a>

I would like to obtain :
<a href="yourlink. html" class="external " alt="">The link</a> (<a
href="yourlink. html" class="external 2" alt="">new window</a>)

So what I would like is the ability to :
1°) Add (<a href="yourlink. html" class="external 2" alt="">new
window</a>) after my original link
2°) indicate by this mean that the link could be followed either on the
same page or another one.
3°) have class="external " that opens nothing and class="external 2" that
opens a new window automaticaly.

What I don't know is :
1°) Is it feasible using only javascript ?
2°) Is it possible only by specifiing class="external " in the original
link (and having javascript doing the subsequent coding) ?
3°) Is someone able to come up with a solution (because I truly can't)

Hope I'll get some expert coders attention ;)

Greetings.

R.
Jul 20 '05 #1
12 3320
Romain wrote:
I've used an excellent way to make target="_blank" links that still
validate while using HTML 4.01 Transitional doctypes in the past.
Oh dear. Opening new windows is not a good idea:
http://diveintoaccessibility.org/day...w_windows.html
I learned the trick from : http://www.sitepoint.com/article/1041


That isn't excellent, it's plain wrong and the document is still invalid.
See:
http://groups.google.com/groups?selm...&output=gplain
--
David Dorward http://david.us-lot.org/
Jul 20 '05 #2
David
I've gotta say "Opening a new window" IS a good idea if it's required.
Don't forget, the bulk of surfing folk are operating a system called....
wait for it.... "Windows", hence the acceptance of windows.
Chillout pal. Write about something important.

Splishman.
"David Dorward" <do*****@yahoo. com> wrote in message
news:bf******** ***********@new s.demon.co.uk.. .
Romain wrote:
I've used an excellent way to make target="_blank" links that still
validate while using HTML 4.01 Transitional doctypes in the past.
Oh dear. Opening new windows is not a good idea:
http://diveintoaccessibility.org/day...w_windows.html
I learned the trick from : http://www.sitepoint.com/article/1041


That isn't excellent, it's plain wrong and the document is still invalid.
See:

http://groups.google.com/groups?selm...&output=gplain

--
David Dorward http://david.us-lot.org/

Jul 20 '05 #3
Lee
"splish" said:

David
I've gotta say "Opening a new window" IS a good idea if it's required.
Don't forget, the bulk of surfing folk are operating a system called....
wait for it.... "Windows", hence the acceptance of windows.


The point is that you must develop your pages to be usable by
everybody, not just "the bulk". If you've got a commercial
web page, you may be in violation of the law if some features
aren't accessible by even a few people.

Jul 20 '05 #4
Lee
Romain said:

Hi,

In article <bf************ *******@news.de mon.co.uk>,
David Dorward <do*****@yahoo. com> wrote:
Romain wrote:
> I've used an excellent way to make target="_blank" links that still
> validate while using HTML 4.01 Transitional doctypes in the past.


Oh dear. Opening new windows is not a good idea:
http://diveintoaccessibility.org/day...w_windows.html


Well at least it's the way I WANT IT... Maybe it's clearer now.
> I learned the trick from : http://www.sitepoint.com/article/1041


That isn't excellent, it's plain wrong and the document is still invalid.
See:
http://groups.google.com/groups?selm...0%40news.demon.
co.uk&output=gp lain

Ok, it's invalid. No argue about that. But still. I wasn't seeking for
your approval, rather for some enlighting pieces of code.


If you're not concerned with validity, why not simply use target="_blank"
when you want a new window and target="_self" (or "_top") when you don't?
Then it will even work for people who have disabled JavaScript.

I know that isn't the answer that you want to hear, but every now and
then somebody will actually seem to appreciate being told that the way
they're asking to do something isn't reasonable.

Jul 20 '05 #5
> >I've gotta say "Opening a new window" IS a good idea if it's required.
Don't forget, the bulk of surfing folk are operating a system called....
wait for it.... "Windows", hence the acceptance of windows.
The point is that you must develop your pages to be usable by
everybody, not just "the bulk". If you've got a commercial
web page, you may be in violation of the law if some features
aren't accessible by even a few people.


Web standards do not have the force of law. That's just nutty.

Jul 20 '05 #6
On Fri, 25 Jul 2003 13:49:04 -0700, "Douglas Crockford"
<no****@laserli nk.net> wrote:
>I've gotta say "Opening a new window" IS a good idea if it's required.
>Don't forget, the bulk of surfing folk are operating a system called....
>wait for it.... "Windows", hence the acceptance of windows.

The point is that you must develop your pages to be usable by
everybody, not just "the bulk". If you've got a commercial
web page, you may be in violation of the law if some features
aren't accessible by even a few people.


Web standards do not have the force of law. That's just nutty.


However a law is free to require adherance to a web standard as part
of its application, such as current Accessibility laws which simply
cite W3's WCAG guidelines as being accessible (and it does require
validity).

Jim.
--
comp.lang.javas cript FAQ - http://jibbering.com/faq/

Jul 20 '05 #7
On Sat, 26 Jul 2003 02:02:44 +1000, "splish" <cm*@congosyste ms.com>
wrote:
David
I've gotta say "Opening a new window" IS a good idea if it's required.
Don't forget, the bulk of surfing folk are operating a system called....
wait for it.... "Windows", hence the acceptance of windows.
Chillout pal. Write about something important.


Yet the largest ISP in the world specifically markets on the fact that
it has a popup-stopper - not that it's fast, not that it's reliable,
but that it stops windows opening - are you sure they're accepted and
that ISP's marketing is just flawed?

Jim.
--
comp.lang.javas cript FAQ - http://jibbering.com/faq/

Jul 20 '05 #8
DU
Lee wrote:
"splish" said:
David
I've gotta say "Opening a new window" IS a good idea if it's required.
Don't forget, the bulk of surfing folk are operating a system called....
wait for it.... "Windows", hence the acceptance of windows.

The point is that you must develop your pages to be usable by
everybody, not just "the bulk". If you've got a commercial
web page, you may be in violation of the law if some features
aren't accessible by even a few people.


Saying that "Opening a new window" is a bad idea is abstract, general,
without any grip on any specific case. 90% of all pages relying on popup
do not use flexible, robust cross-browser code and have no concerns
about accessibility and usability.
Nevertheless, a page using popups can be a respectable and responsible
webdesign decision.

DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/

Jul 20 '05 #9
On Sat, 26 Jul 2003 12:47:27 -0400, Romain <us**@domain.tl d> wrote:
Oh, and by the way, I neither live in the US nor in the UK, I don't have
a commercial web site, and I really don't care about ADA, DAA (american
only RECOMMENDATIONS ).
Guessing from headers at you being in the same country as me:

http://www.w3.org/WAI/Policy/#Canada

but as you note you're not doing commercial (this would include
Government or charity or many other organisations, home publishing it
wouldn't) it matters little to you, however in discussing stuff on the
group, many of us do care, so it is still relevant to point stuff out.
I just want to offer a convenient (don't argue with that last personnal
opinion please) way to choose between opeing a link in the same window,
or in a new one, by LETTING the user do the choice.


That's good, and is certainly more accessible than most (there's
problems with what happens when you take links out of context as many
AT's do in your example but it's not too serious)

Jim.
--
comp.lang.javas cript FAQ - http://jibbering.com/faq/

Jul 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
7688
by: Sugapablo | last post by:
I admit, I'm terrible creating reg ex's. I'm trying to create a preg_replace that would remove from a <a href> tag that would replace the target attribute regardless of what the value might be. Any ideas? --
1
1967
by: Nick Messick | last post by:
I'm going through some old code and have found this a number of places. Seems kind of strange. Is there any reason why someone would do this?
16
3619
by: St. Rechsteiner | last post by:
Hi How i made the same effect in xHTML like the - target="_blank" - Tag in HTML 4.01? I will use it with xHTML and CSS ... but the validator say's to me, that this tag wasn't valid for xHTML! ... Why? Is there no "same effect"-Tag in xHTML? Thx for answers!
6
77511
by: Tony Marston | last post by:
The code <a href="..." target="_blank">...</a> will not validate as XHTML STRICT because of the 'target' tag, so how do I achieve the same result by moving it to a CSS file? I cannot find anything which allows me to specify 'target=' on an anchor tag. -- Tony Marston http://www.tonymarston.net
2
2845
by: Matt | last post by:
In the following code, page1.asp is inside the frame of main.html. When the user click submit button in page1.asp, it will submit the form and open a new window called page2.asp. When the user clicks submit button on page2.asp, I expected to open a new window called page3.asp. Unfortunately, it just open page3.asp in the same window as page2.asp, and now page2.asp is gone. However, if I just open page1.asp, and begins from there, it is...
10
60725
by: Dieter Salath? | last post by:
Hi, in our webpage, a user could open a windows explorer to his temp directory with a simple link and usage of the file protocol: <a href="file://C:\temp" target="_blank">C:\temp</a> This worked very well a long time, but now it does not work anymore. We use IE6 and Microsoft Windows XP Professional 2002 SP2. I guess it has something to do with new IE security features. Does
8
3860
by: msnews.microsoft.com | last post by:
I want to redirect the user to a url outside of our website but I want it to preserve our application's window by opening a new window. We have a datagrid that has five hyperlink columns containing links to external sites. The hyperlink columns have the target="_blank" attribute so they preserve the existing window. This works OK except that the NavigateURL's are quite long due to the size of the query string and this makes the page slow. ...
5
3991
by: Jon via DotNetMonster.com | last post by:
<siteMapNode title="share price" description="Link to Netcall on the London Stock Exchange" url="http://www.yahoo.co.uk" role="" target="_blank" /> Hi all I'm trying to open the Yahoo web site in a new window using the above code in my asp.net web.sitemap. I'm expecting the target="_blank" bit to make it do this. but it isnt. Does anyone know why?? Thanks in advance.
1
4630
by: =?Utf-8?B?Sko=?= | last post by:
Hi all, I have a help page that I have to (against my better judgement) open up in a new window, which will show the help for the current page the user is on. So in my master page I have a bulletedlist that I populate at runtime (so that I can put a request variable on the link in the listitem's value property). <asp:BulletedList runat="server" ID="lstHelp" Target="_blank" DisplayMode="HyperLink"></asp:BulletedList> This all works...
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9535
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10242
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10021
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5453
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4127
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.