PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTML » Pager » Bug #6005

During POST request, use href="javascript:void(0);" instead of href="#"

Details

Request #6005During POST request, use href="javascript:void(0);" instead of href="#"
Submitted2005-11-17 23:30 UTC
Fromremi at metacore dot net
Assignedquipo
StatusClosed
PackagePager
PHP Version5.0.5
OSLinux
Roadmaps(Not assigned)

Comments

[2005-11-17 23:30 UTC] remi at metacore dot net

Description:
------------
Observed in Pager 2.3.4.

When using the method 'POST' for pager, it would be IMHO better to use 'javascript:void(0);' instead of '#' for the link target.

This is because recent browsers do absolutely nothing when confronted with javascript:void(0), whereas when you have '#' therein, often the browser will jump to the top of the page/move around in an unanticipated manner.

It's a straightforward change, I think, and one that could be made to the core package without fear of breaking things.

To make this code change is a one-line modification.

Line 669 of Pager/Common.php is modified from:

return sprintf('<a onclick=\'%s\' href="#"%s title="%s">%s</a>',

to:

return sprintf('<a onclick=\'%s\' href="javascript:void(0);"%s title="%s">%s</a>',

Expected result:
----------------
With javascript:void(0), the browser doesn't do anything except for load the next page, which would be my preference.

Actual result:
--------------
Any POST method use of Pager will demonstrate this, depending on the browser used. Firefox 1.0.7 demonstrates it (click on a pager link at the bottom of a page when the Pager method is 'POST') -- it will jump to the top of the page before actually following the javascript commands and loading the next page. This is disconcerting, IMHO.