تصف هذه المقالة طريقة تنفيذ JS لمسح ملفات تعريف الارتباط المحددة ، وهو أمر عملي للغاية. شاركه للرجوع إليه.
رمز التنفيذ المحدد كما يلي:
وظيفة getCoOkievalue (name) {var cookievalue = null ؛ if (document.cookie && document.cookie! = '') {var cookies = document.cookie.split ('؛') ؛ لـ (var i = 0 ؛ i <cookies.length ؛ i ++) {var cookie = jQuery.trim (ملفات تعريف الارتباط [i]) ؛ // pyyh = username = steven & password = 111111 & userId = 1 & userType = 1 if (cookie.substring (0 ، name.length + 1) == (name + '=')) {cookievalue = decodeuricomponation (cookie.substring (name.length + 1))) ؛ // username = Steven & Password = 111111 & userId = 1 & userType = 1 break ؛ }}} return cookievalue ؛} دالة delcookie (name) {var exp = new date () ؛ exp.Settime (exp.getTime () + (-1 * 24 * 60 * 60 * 1000)) ؛ var cval = getCoOkievalue (name) ؛ document.cookie = name + "=" + cval + "؛ expires =" + exp.togMtString () ؛} exit () {delcookie ("pyyh") ؛ window.location.replace ("http: // localhost: 7877/index.aspx") ؛}آمل أن تكون هذه المقالة مفيدة لتعلم كل شخص يعلم البرمجة الأمامية على شبكة الإنترنت.