target =" _blank" ...但更好? [英] target="_blank"... but better ?

查看:66
本文介绍了target =" _blank" ...但更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我用了很好的方法来制作target =" _blank"过去使用HTML 4.01 Transitional doctypes时仍然有效的链接。


我从中学到了这个技巧: http://www.sitepoint.com/article/1041


基本上而不是输入:

< a href =" yourlink.html"目标= QUOT; _blank" alt ="">链接< / a>


您输入:

< a href =" yourlink.html"类= QUOT;外部" alt ="">链接< / a>


由于这个小小的javascript,它也是一样的:


/ * Evite de mettre des target =" _blank" * /

函数externalLinks(){

如果(!document.getElementsByTagName)返回;

var anchors = document.getElementsByTagName(" a" ;);

for(var i = 0; i< anchors.length; i ++){

var anchor = anchors [i];

if(anchor.getAttribute(" href")&&

anchor.getAttribute(" class")==" external")

anchor。 target =" _blank";

}

}

window.onload = externalLinks;


现在,虽然这完美无缺,但我希望我可以做一些更多的事情(在你的帮助下)。


我想要的是什么如下:


键入:

< a href =" yourlink.html"类= QUOT;外部" alt ="">链接< / a>


我想获得:

< a href =" yourlink.html" ;类= QUOT;外部" alt ="">链接< / a> (< a

href =" yourlink.html" class =" external2" alt =""> new window< / a>)


所以我想要的是能够:

1°)添加(< a href =" yourlink.html" class =" external2" alt =""> ;新的

窗口< / a>)在我的原始链接后

2°)表明这个链接可以跟在
$ b上$ b同一页或另一页。

3°)有class =" external"没有打开,class =" external2"那个

自动打开一个新窗口。


我不知道的是:

1°)是否可行仅使用javascript?

2°)是否可以通过指定class =" external"在原来的

链接中(并且javascript正在进行后续编码)?

3°)是否有人能够提出解决方案(因为我真的不能)


希望我会得到一些专家编码员的关注;)


问候。


R.

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.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("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="external2" alt="">new window</a>)

So what I would like is the ability to :
1°) Add (<a href="yourlink.html" class="external2" 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="external2" 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.

推荐答案

Romain写道:
我用了一种很好的方法来制作target =" _blank ;在过去使用HTML 4.01 Transitional doctypes时仍然可以验证的链接。


亲爱的。打开新窗口并不是一个好主意:
http://diveintoaccessibility.org/day ... w_windows.html

我从中学到了诀窍: http://www.sitepoint.com/article/1041
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




这不是很好,这是完全错误的该文件仍然无效。

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

-

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


David

我必须说打开一个新窗口如果需要的话,这是一个好主意。

别忘了,大多数冲浪民众正在运行一个叫做的系统....

等待它....Windows,因此接受了Windows。

Chillout pal。写下重要的事情。


Splishman。

David Dorward <做***** @ yahoo.com>在消息中写道

新闻:bf ******************* @ news.demon.co.uk ...
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*******************@news.demon.co.uk...
Romain写道:
我使用了一种很好的方法来制作target =" _blank"过去在使用HTML 4.01 Transitional doctypes时仍然有效的链接。
哦亲爱的。打开新窗口并不是一个好主意:
http://diveintoaccessibility.org/day ... w_windows.html
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
我从中学到了这个技巧: http://www.sitepoint.com/article/1041
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 /



" splish"说:
"splish" said:

大卫
我必须说打开一个新窗口如果需要的话,这是一个好主意。
不要忘记,大多数冲浪民众正在运行一个名为......
等待它的系统......Windows因此接受了窗户。

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.




重点是你必须开发你的页面才能被所有人使用,而不仅仅是b $ b。批量如果您有一个商业

的网页,如果某些功能即使是少数人也无法访问,那么您可能会违反法律。



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.


这篇关于target =&quot; _blank&quot; ...但更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆