querystring truncated

1 view
Skip to first unread message

Chunlei Wu

unread,
Jul 31, 2008, 7:43:37 PM7/31/08
to dshistory-discuss
Hi,

I am using the dsHistory.js from the trunk (rev68). It works
nicely (also works for Safari3)! But I am having a issue I can not
figure out.

In my webapp, I have these these links managed by dsHistory:

http://host/#goto=about
http://host/#goto=terms
http://host/#goto=help
http://host/#goto=report&id=695

The first three links are associated with Tabs ("About",
"Terms", "Help") and the last is associated with a button click, which
needs an extra parameter id. This is an example of javascript code:

if (!historyObject || !historyObject.calledFromHistory) {
for (attribute in dsHistory.QueryElements){
dsHistory.removeQueryVar(attribute);
}
dsHistory.setQueryVar('goto', 'about');
dsHistory.bindQueryVars(renderAbout);
}

Note that I add a for-loop first to remove any existing
parameters (otherwise, I will get http://host/#goto=about&id=695
instead of http://host/#goto=about, if I click "About" tab from page
http://host/#goto=report&id=695).

However, this gives me another problem.

If I starts from the main page http://host/, when I click "About", the
"About" tab is shown and the URL is changed to the first one above.
Then when I click "Terms" tab, the URL is not shown as the second one,
but this truncated one:

http://host/#erms

Then when clicking "Help" tab, it becomes this of course.

http://host/#erms&goto=help


I also noticed that if my keyword is not the first one in
querystring, it does not cause the truncation. For example, if I start
the page as:

http://host/#_

then, clicking through each tab, the url is shown as the
following, nothing is truncated:

http://host/#_&goto=about
http://host/#_&goto=terms
http://host/#_&goto=help


I believe that is the problem with the for-loop in my code, but I
don't know how to fix it. Maybe this is not the right way of cleaning
up exisiting querystring?

Thanks.

Chunlei

Reply all
Reply to author
Forward
0 new messages