JS Object-Oriented Learning note eight (cookie used with URL get parameter gets)

Source: Internet
Author: User


1. Use of cookies

<script src= "Http://code.jquery.com/jquery-1.9.0.min.js" ></script><script src= "./jquery.cookie.js "></script><script>    //This setting is one by one corresponding to the default cookie scope for the current folder under $.cookie (" Favourite-city "," London ");    $.removecookie ("favourite-city");    Set the cookie    $.cookie ("favourite-city", "London", {path: "/", Domain: "test.com"}); $.removecookie ("Favourite-city ", {path:"/", Domain:" test.com "}); Gets the cookie variable $.cookie ("favourite-city");//Set expiration date    var date = new Date (), var m = 6;//minutesdate.settime ( Date.gettime () + (M * +));   $.cookie (Key,value, {expires:date});//or $.cookie ("favourite-city", "", {expires:new date (+, +,-one, XX, xx), sec Ure:true});</script>



2. Get parameter of URL address

<script>/** * Gets the Get parameter on the URL */function geturlparameter (sParam) {    var spageurl = Window.location.search.substring (1);    var surlvariables = spageurl.split (' & ');    for (var i = 0; i< surlvariables.length; i++) {        var sparametername = surlvariables[i].split (' = ');        if (sparametername[0] = = SParam) {            return sparametername[1]        ;          }} /* Use example */var tech = Geturlparameter (' technology '), var blog = geturlparameter (' blog '), alert (tech); alert (blog); </ Script>




JS Object-Oriented Learning note eight (cookie used with URL get parameter gets)

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.