javascript javascript类示例
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript javascript类示例相关的知识,希望对你有一定的参考价值。
var countryCookieRedirect = {
internationalUrl: '',
intlCookieName: '',
visitorCountry: '',
cookie: Cookies.get('ct_location'),
urlRedirect: '',
cookieCountyCode: '',
checkCookie: function () {
if (countryCookieRedirect.cookie) {
if (countryCookieRedirect.cookie === countryCookieRedirect.intlCookieName) {
document.location.href = countryCookieRedirect.internationalUrl;
} else {
document.location = document.location.protocol + '//' + document.location.host + '/' + countryCookieRedirect.cookie + '/';
}
}
},
setCookieVisitorLocation: function(){
Cookies.set(
'ct_location',
countryCookieRedirect.cookieCountyCode,
{expires: 3653, path: '/'}
);
},
checkAndSetVisitorCookie: function(){
if ( ! countryCookieRedirect.cookie || countryCookieRedirect.cookie === 'undefined') {
countryCookieRedirect.setCookieVisitorLocation(countryCookieRedirect.cookie);
if (countryCookieRedirect.visitorCountry === countryCookieRedirect.intlCookieName) {
document.location.href = countryCookieRedirect.internationalUrl;
} else {
document.location = countryCookieRedirect.urlRedirect;
}
}
}
};
以上是关于javascript javascript类示例的主要内容,如果未能解决你的问题,请参考以下文章
javascript 构造函数与类示例
21种JavaScript设计模式最新记录(含图和示例)
Javascript - 获取函数(方法)的类所有者
javascript 类数组对象
如何在 JavaScript 中继承 C++ 类?
如何将 JavaScript 类实例与对象合并?