JavaScript location.href Implementation Select Jump Effect

Source: Internet
Author: User

A single description of location properties, usage, and related examples:
Location
Contains information about the current URL.

Describe
The Location object describes the complete URL associated with a given Window object. Each property of the location object describes the different attributes of the URL.
Typically, a URL will have the following format:

Protocol/HOST: Port/path name # Hash ID? search criteria

<script language= "Web Effects" >
function Gotourl (URL)
{
Location.href=url;
}
</script>

<select name= "" Onchange= "Javascript:gotourl (this.value);" >
<option value= "/user/online.php Tutorial" > select display Mode </option>
<option value= "/user/online.php?t=1". if ($t ==1) {echo ' selected= ' selected ';}? > > Only show Handsome guy </option>
<option value= "/user/online.php?t=2". if ($t ==2) {echo ' selected= ' selected ';}? >> Show only Beauty </option>
</select>


Protocol return address Protocol, value ' http: ', ' HTTPS tutorial: ', ' File: ' And so on.

Hostname return address host name, for example, a "http://www.zutiai.com.com/n86/" address, Location.hostname = = ' www.microsoft.com '.

Port returns the port number of the address, and the general HTTP port number is ' 80 '.

Host returns the hostname and port number, such as: ' www.a.com:8080 '.

Pathname returns the path name, such as "http://www.a.com/b/c.html", location.pathname = = ' b/c.html '.

Hash returns "#" and later content, such as "http://www.a.com/b/c.html#chapter4", Location.hash = = ' #chapter4 '; if there is no "#" in the address, an empty string is returned.

Search return "?" and later content, such as "http://www.a.com/b/c.asp tutorial? selection=3&jumpto=4", Location.search = = '? selection=3&jumpto= 4 '; If there is no "?" in the address, an empty string is returned.

HREF returns all of the above, that is, return the entire address. How to show it on the browser's address bar is how to return it. If you want a window object to open an address, you can use "Location.href = ' ... '", or you can use "location = ' ... '" to do this.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.