Ctrl +单击与点击链接的处理程序 [英] Ctrl+click on links with click handlers
问题描述
我有一个链接(锚)具有附加给它一个href导航到一个特定的网址www.bla.com'。
< A HREF =HTTP://www.bla.com/>
我也有附加到执行一些操作,然后打开在同一窗口中的HTML视图链接的点击
处理程序。一切都运行得很好。
然而,当用户使用Ctrl +单击打开一个新标签/窗口中的链接,单击处理似乎采取precedence并打开在同一窗口中的HTML视图。但是,我想保留Ctrl +单击的行为,并允许用户打开一个新标签/窗口中的链接(就像一个正常的链接)。我怎么能这样做呢?
在此先感谢!
函数方法(e){
VAR EVT = E? E:window.event;
如果(evt.ctrlKey)
警报(ctrlClicked);
}
evt.ctrlKey如果控制键是pressed将返回true,则可以在写你的条件,如果块,我测试只铬和FF。
I have a link (anchor) that has an href attached to it to navigate to a specific URL say 'www.bla.com'.
<a href='http://www.bla.com' />
I also have an click
handler attached to the link that performs some actions and then opens an html view in the same window. Everything works perfectly well.
However, when the user uses 'ctrl+click' to open the link in a new tab/window, the click handler seems to be taking precedence and opens the html view in the same window. But I want to retain the 'ctrl+click' behavior and allow the user open the link in a new tab/window (just as a normal link). How could I do that?
Thanks in advance!
function process(e){
var evt = e ? e:window.event;
if(evt.ctrlKey)
alert("ctrlClicked");
}
evt.ctrlKey will return true if control key is pressed, you can write your conditions within "if" block, I tested this for chrome and ff only.
这篇关于Ctrl +单击与点击链接的处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!