views:

23

answers:

3

Just a curiousity rather than an acutal need, I've never thought about this, but I can't think of any html which would do this. I could do it in Javascript or Serverside easy enough, but curious if browers can implement this anyway.

Say I'm at a url: http://www.mysite.com/?param1=10

and I have an <a> tag, is there anyway to make it's href so that it will append a new parameter to the qs?

So I could have <a href='?param2=20'>Twenty</a> which would make the url http://www.mysite.com/?param2=20. But I want it to be http://www.mysite.com/?param1=10&amp;param2=20. Conversely if I was on http://www.mysite.com/?param1=10&amp;param2=20 and there was a link to turn the url into http://www.mysite.com/?param1=30&amp;param2=20, by only specifiying the param1 parameter in the tag? <a href='?param1=20'>10</a>.

If that makes sense? So can this be done just with html, no js or serverside, and not form submissions, just <a> tags?

+3  A: 

Short answer: no. HTML is not a programming language, just a markup language.

egrunin
+1 for emphasising that HTML is a markup language
Gary Rowe
A: 

No, it can't be done. Links can be relative to the site (with leading slash):

<a href="/some/page.html">link</a>

or to the page (no slash)

<a href="someotherpage.html">link</a>

they can lead to a local anchor ( with a #)

<a href="#anchorname">link</a>

or they can be absolute

<a href="http://www.mysite.com/foo/bar/phleem.html"&gt;link&lt;/a&gt;

or of course combinations of the above with local anchors.

But they can't append to the query string.

seanizer
A: 

With HTML, no.

In Javascript it's doable: one function to parse the current querystring and an another one to catch the clicks on elements for appending and subsequent redirection.

Saul