Overiding/Appending querystrings - html

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&param2=20. Conversely if I was on http://www.mysite.com/?param1=10&param2=20 and there was a link to turn the url into http://www.mysite.com/?param1=30&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?

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

No, it can't be done. Links can be relative to the site (with leading slash):
link
or to the page (no slash)
link
they can lead to a local anchor ( with a #)
link
or they can be absolute
link
or of course combinations of the above with local anchors.
But they can't append to the query string.

Related

HTML: href of anchor. How to concatenate instead of replace?

I am in the page
www.myWebsite.com/registration?type=lookfor
And in the menu I have an anchor to change the language.
English
If I click on this anchor, I will be redirect to
www.myWebsite.com/registration?lang=en
... but the correct result would be
www.myWebsite.com/registration?type=lookfor&lang=en
I could easily elaborate a javascript solution, but I would like to have a simple HTML solution, if there is any.
English
Try this html code for redirect with two query strings

PHP and html how do i link to an external URL?

consider the following code:
<a id="alink" href="http://google.com">google</a>
This is a fairly basic link tag. At the top of my html page I have:
<base href="//localhost/website/" />
This creates a problem, when i click my link it brings me to:
//localhost/website/http://google.com
I do not want this, I want it to bring me to a completely different site(google.com for example). How can I fix this problem?
try this one.
<base href="http://localhost/website/" />
on localhost no need for directory or double slashes // !=link.
The effect of the base tag is global to the document, and the only way to override the effect of  is to use absolute URLs.
You can use window.location in JavaScript to get the URL of the page itself, in case the document was retrieved via HTTP. And you could use it to construct absolute URLs.
But It is better to use server-side technologies that let you construct addresses from one or more base addresses. So quite possibly the best approach is to get rid of the tag.

What is the <A W3MIRHREF> tag in HTML?

in a .html file I have found the following code:
<!DOCTYPE HTML PUBLIC "html.dtd">
<HTML>
<P><A W3MIRHREF="http://www.myCompany.org/division/subdivision/repec/handle/wpaper/wp-02-01.rdf" HREF="wp-02-01.rdf">wp-02-01.rdf</A></P>
</HTML>
What exactly mean the W3MIRHREF attribute? I never see it, I always say the classic tag
What is this? and for what is used?
Tnx
Andrea
This attribute is added to a link by w3mir utility:
w3mir is a all purpose HTTP copying and mirroring tool. The main focus
of w3mir is to create and maintain a browsable copy of one, or
several, remote WWW site(s).
This particular attribute is used to store a link to the original document.
The W3MIRHREF has no meaning in any HTML recommendation.
I'd speculate that it is a regular href attribute with a bunch of random characters prepended to it so that browsers will ignore it. i.e. w3mir is a pseudo-comment.

Retrieve all hashes in a page for URL use

I am trying to copy a link from this site (stack overflow), but I like the link to include a hash so when someone clicks on the link they go directly to the answer I would like them to see. How can I find the hashes in a page?
Example:
http://www.blahblah.com/index.php#label
How can I know there is a #label, and how to find it?
The value of the hash is simply the ID attribute of any element in the page.
You can see them in the source or the DOM inspector.
Are you looking for something like this?
var hash = window.location.hash;
There might not be a simple answer for your here. In a pure HTML context (i.e. excluding javascript functionality). The has would reference an anchor on the page like this:
<a name="label"></a>
So you could just look for named anchors.
Now, if you are talking about javascript functionality it gets much more complex. Via javascript you can use a hash tag like that and make it do any number of things (like show a hidden element with id="label", download some content asynchronously based on that hash, etc. So there might not be an easy way to determine allowable values.

Meaning of "#" when it is used like this href="#"

I have been following this tutorial to learn how to use Scrapy. I am using greenbook as my sample site to test out the web scraping. One of the function: SgmlLinkExtractor takes in a parameter which is the href of the "next" page button . The problem is that for greenbook , the href for the "next" page button is a "#" if you inspect the element via firefox
These are my questions
1) What does "#" mean when used in this way : href="#"
2) How do i solve this issue
Thanks
You can use # to point to an ID on the page rather than redirect to a URL.
When you see stuff like "Click here to scroll to the bottom of the page`
The here href will be #bottomOfPage
http://jsfiddle.net/2q3NJ/
The attribute href="#" means the same as href="", i.e. a reference to the start of the current document. It is seldom used with the intention of linking to the start, however. Instead, it is used a placeholder that makes the a element formally a link, and also a link from styling point of view, but in a context where the element is expected to have an onclick event handler or to have its href value overwritten.
Cf. to Is an empty href valid? and Which "href" value should I use for JavaScript links, "#" or "javascript:void(0)"?
In your case, it sounds like the software you are using generates next page “links” that are not real links but driven by JavaScript and carrying href="#" as a placeholder only. This does not work with other software that expects href attributes to be real. It depends on both pieces of software whether and how you can make them work together.