URL Parameters and url Encoding
This is a follow up of my last blog: bit.ly/1k10Lit
Create a html file (example.html) and paste this code and save.
Open the file, type some text and hit enter.
Notice the change in the url before and after you hit enter
<form>
<input name="q"> [notice there is no closing tag of input hence it is VOID TAG]
</form>
ex:
suppose text you entered is: apple
Before hitting enter: file://tmp/example.html
After hitting enter: file://tmp/example.html?q=apple
<Submit> tag :
It creates a button inside your form.
Code: <input type="submit">
Url parameter is created automatically (i.e. ?q=apple)
Action attribute of a <form>:
Now create another html file search.html and paste this code.
save it and load it as html.
<form action="http://www.google.com/search">
<input name="q">
<input type="submit">
</form>
After it loaded, type some text and hit submit.
ex: if i type book
Browser will redirect it to google search result of what you have typed.
Check the value of q now.
http://www.google.com/search?q=book
http://www.google.com/search?q=book
Notice the value of q
http://www.google.com/search?q=better+flight+search
See the pluses between the values we given. These are called URL ENCODING.
it basically replaces whitespace with pluses and Special characters into %'s
if i type book!
the value of q now.
http://www.google.com/search?q=book%21
Hope you understood how the url parameters work.
Comments
Post a Comment