防止Chrome中的链接点击中的光标更改 [英] Preventing cursor change on link click in Chrome

查看:151
本文介绍了防止Chrome中的链接点击中的光标更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

点击Chrome中的链接(而不是Safari或Firefox)会将光标从指针更改为箭头。可以防止这种行为吗?也就是说,点击后仍然可以有指针,但是光标仍然悬停在链接上?



编辑:好吧,所以我做了一些更多测试。首先,任何人都希望光标在点击链接后保持为指针的唯一原因是链接实际上并未加载另一个页面,而是触发JS事件。

 < a href =test>测试< / a> 

// JQuery
$(a)。click(function(event){event.preventDefault();}

使用上面的代码,event.preventDefault(或返回false)将允许游标在点击后保持为指针。这将足以满足大多数用途,即触发DOM操作和/或AJAX请求。



问题是history.pushState():

 < a href =test>测试< / a> 

// JQuery
$(a
history.pushState(arg1,arg2,url);
event.preventDefault(); return false;
}

这里的指针变成了箭头。有关如何阻止这种情况发生的任何想法?

解决方案

这听起来像一个CSS问题。寻找如下代码:

  ::  -  webkit-any -link:hover,
:: - webkit-any-link:active {cursor:pointer;}


$ b b

这将影响所有链接(如 a [href] ),但仅在WebKit中。



更新版本:

现在我们更多地了解这个问题,也就是说,在点击元素触发javascript之后,光标变回指针,我会说这是一个Chrome错误。



请在 http://bugs.chromium.org/ 提交报告


Clicking on a link in Chrome (not Safari or Firefox) changes the cursor from pointer to arrow. Can this behavior be prevented? I.e., is it possible to still have the pointer after clicking, but while the cursor is still hovering over the link?

EDIT: Okay so I've done a little more testing. First of all, the only reason anyone would want the cursor to remain as a pointer after clicking on a link is if the link does not actually load another page but rather fires a JS event instead.

<a href="test">Test</a>

// JQuery
$("a").click(function(event) { event.preventDefault(); }

With the above code, event.preventDefault (or returning false) will allow the cursor to remain a pointer after click. This will suffice for most uses, namely triggering a DOM manipulation and/or AJAX request.

The problem is with history.pushState():

<a href="test">Test</a>

// JQuery
$("a").click(function(event) {
    history.pushState(arg1, arg2, url);
    event.preventDefault(); return false;
}

Here the pointer DOES change to an arrow. Any ideas on how to stop that from happening?

解决方案

This sounds like a CSS issue. Look for code like the following:

::-webkit-any-link:hover,
::-webkit-any-link:active { cursor: pointer; }

This will affect all links (like a[href]) but only in WebKit. Perhaps something else is preventing Safari from doing this.

UPDATE GIVEN EXPANDED QUESTION:

Now that we know more about the problem, namely that the cursor changes back to a pointer after clicking on an element fires off a javascript, I would say that this is a Chrome bug.

Please file a report at http://bugs.chromium.org/

这篇关于防止Chrome中的链接点击中的光标更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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