JS method of accessing or setting cookies + cross-domain calling method

Source: Internet
Author: User

Accidentally access or set cookies from the 163 web site, log to the log to prevent forgetting

Cookie function Check
function Fcheckcookie () {
if (!navigator.cookieenabled) {
Alert ("Hello, your browser settings prohibit use of cookie\n please set your browser, enable the cookie feature, and then login again.") ");
}
}

//Get cookie
function Fgetcookie (sName) {
   var ssearch = sName + "=";
   if (document.cookie.length > 0) {
      offset = document.cookie.indexOf ( Ssearch)
      if (offset! = 1) {
         Offset + = Ssearch.length;
         end = Document.cookie.indexOf (";", offset)
          if (end = =-1) end = Document.cookie.length;
         return unescape (document.cookie.substring (offset, end))
     
      else Return ""
  }
}

Set cookies
function Fsetcookie (name, value, Isforever, domain) {
var sdomain = ";d omain=" + (Domain | | goption["Scookiedomain"]);
Document.cookie = name + "=" + Escape (value) + Sdomain + (isforever? "; Expires= "+ (new Date (2099,12,31)). toGMTString ():" ");
}

/cross-Domain call method
function Fgetscript (sURL) {
var oscript = document.createelement ("script");
Oscript.setattribute ("type", "Text/javascript");
Oscript.setattribute ("src", surl);
Try{oscript.setattribute ("Defer", "defer");} catch (e) {}
Window.document.body.appendChild (Oscript);
}

JS method of accessing or setting cookies + cross-domain calling method

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.