Closed
Bug 417252
Opened 17 years ago
Closed 16 years ago
"location.hash" property doesn't replace the hash correctly on the second time.
Categories
(Firefox :: General, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 429128
People
(Reporter: danielpereira, Unassigned)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12
When i write (the first time) on the document.location.hash, the browser cache the position on URL. When i write a second time and search options changes (load the same page with different search options) it replaces the text on the position cached by the browser on the first time. But, the search options change length, so it is really replace the search options, and not changing the hash.
Reproducible: Always
Steps to Reproduce:
1.
URL: http://noserver.com/support/admins/body.php?mod=users
PRINT: document.location.search ==> "?mod=users"
PRINT: document.location.hash ==> "" // Empty string
//Using the onclick event for an input button i call the following
function changePageRows(obj){
// form.PageRows - number of rows for a table (this is a input text box)
PageRows=parseInt(obj.form.PageRows.value);if(isNaN(PageRows)||PageRows<=0)PageRows=10;
if(document.location.search.indexOf("pagerows=")!=-1){search=document.location.search.replace(/pagerows=(\+|\-){0,1}[0-9]+/g,'pagerows='+PageRows)}
else{search=document.location.search+'&pagerows='+PageRows;}
// search = if pagerows exist replace, else append
// for this example pagerows is append, search = '?mod=users&pagerows=10' ,
//assuming the PageRows=10
// when clicked i like to go to anchor call 'NAV'
document.location.hash='NAV'
// Now i went to reload the page with the new pagerows settings
document.location.search=search
}
The page is redirect to:
URL: http://noserver.com/support/admins/body.php?mod=users&pagerows=10#NAV
PRINT: document.location.search ==> "?mod=users&pagerows=10"
PRINT: document.location.hash ==> "NAV"
So far is working correctly.
2.Now the browser is on the same page but with different "search" options
URL: http://noserver.com/support/admins/body.php?mod=users&pagerows=10#NAV
PRINT: document.location.search ==> "?mod=users&pagerows=10"
PRINT: document.location.hash ==> "NAV"
When i click again on the SAME button, it calls again the same function:
changePageRows(obj){
PageRows=parseInt(obj.form.PageRows.value);if(isNaN(PageRows)||PageRows<=0)PageRows=10;
if(document.location.search.indexOf("pagerows=")!=-1){search=document.location.search.replace(/pagerows=(\+|\-){0,1}[0-9]+/g,'pagerows='+PageRows)}
else{search=document.location.search+'&pagerows='+PageRows;}
/***E R R O R *****************************************/
// Before i write on the location.hash, i read the result
alert(document.location.hash) --> "#pag" - WRONG, it must return "NAV" which is
//the anchor on the URL
// ---> This result is the substring of this search URL, on the same position
//and length of the HASH of the first link (see URL of the 1. item)
alert(document.location.search) --> "?mod=users&pagerows=10"
/************************/
document.location.hash='NAV'
document.location.search=search
}
It redirects to:
URL: http://noserver.com/support/admins/body.php?mod=users&NAVerows=10#NAV
PRINT: document.location.search ==> "?mod=users&NAVerows=10" <---- it WRITE the
//NAV hash on the first position
PRINT: document.location.hash ==> "NAV"
Actual Results:
URL: http://noserver.com/support/admins/body.php?mod=users&NAVerows=10#NAV
Expected Results:
URL: http://noserver.com/support/admins/body.php?mod=users&pagerows=10#NAV
The browser can't cache the position of the location.hash. It must always search and replace the location.hash.
Reporter | ||
Comment 1•17 years ago
|
||
The search options is document.location.search property, and the hash is document.location.search property
Reporter | ||
Comment 2•17 years ago
|
||
Sorry,
"... and the hash is document.location.hash property."
Reporter | ||
Updated•17 years ago
|
Severity: normal → major
Reporter | ||
Updated•17 years ago
|
Version: unspecified → 2.0 Branch
![]() |
||
Updated•16 years ago
|
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•