开发者

Preventing cursor change in Chrome when clicking on a link that calls history.pushState() [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Preventing cursor change on link click in Chrome

Clicking on a link in Chrome (not 开发者_开发百科Safari or Firefox) that results in a call to history.pushState() changes the cursor from pointer to arrow. Can this behavior be prevented?

Example:

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():

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

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


Have you tried some CSS:

a {cursor: pointer;}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜