var mytime;
function getPramJs(param) {
var query = window.location.search.substring(1);
var parms = query.split('&');
for (var i=0; i<parms.length; i++) {
var pos = parms [ i ].indexOf('=');
if (pos > 0) {
var key = parms [ i ].substring(0,pos).toLowerCase();
var val = parms [ i ].substring(pos+1);
if(key == param.toLowerCase())
return val;
}
}
return null;
}
$(document).ready(function () {
var edit ="";
edit = getPramJs("edit");
var chkCounty = getCookie("country");
var chkCity = getCookie("city");
if(chkCounty != null){
$("#country").val(chkCounty);
}
if(chkCity != null){
$("#city").val(chkCity);
}
if((chkCounty != null)&&(chkCity != null)){
$('#firt').css({'display':'none'});
$('#change').css({'display':'block'});
if(chkCity=="city 3"){
$('#content').css({'display':'block'});
}
mytime = setInterval(function(){ redirect() }, 1000);
if(edit=="1"){
change();
}
}else{
$('#firt').css({'display':'block'});
$('#change').css({'display':'none'});
}
});
function myStopmytime() {
clearInterval(mytime);
}
// Set cookie
function setCookie(name, value, exdays, path, domain, secure) {
var expires=new Date();
expires.setDate(expires.getDate() + exdays);
document.cookie = name + "=" + escape(value) +
((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
((path == null) ? "" : "; path=" + path) +
((domain == null) ? "" : "; domain=" + domain) +
((secure == null) ? "" : "; secure");
}
// Read cookie
function getCookie(name){
var cname = name + "=";
var dc = document.cookie;
if (dc.length > 0) {
begin = dc.indexOf(cname);
if (begin != -1) {
begin += cname.length;
end = dc.indexOf(";", begin);
if (end == -1) end = dc.length;
return unescape(dc.substring(begin, end));
}
}
return null;
}
//delete cookie
function eraseCookie (name,path,domain) {
if (getCookie(name)) {
document.cookie = name + "=" +
((path == null) ? "" : "; path=" + path) +
((domain == null) ? "" : "; domain=" + domain) +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}
function change(){
$('#firt').css({'display':'block'});
$('#change').css({'display':'none'});
myStopmytime();
}
function showdirec(){
$('#firt').css({'display':'none'});
$('#change').css({'display':'block'});
}
function saveLocation(){
var country = $( "#country option:selected" ).text() +"";
if(country != "select your country"){
eraseCookie("country");
setCookie("country",country,365);
}else{
}
if(city != "select your city"){
var city = $( "#city option:selected" ).text() +"";
eraseCookie("city");
setCookie("city",city,365);
}else{
}
redirect();
//showdirec();
}
function redirect(){
var lol = "http://pmckw.com";
var chkCity = getCookie("city");
if(chkCity =="city 1"){
lol= "http://pmckw.com";
}
if(chkCity =="city 2"){
lol= "https://www.google.com/";
}
if(chkCity=="city 3"){
lol= "kuwait.html";
}
if(chkCity =="city 4"){
lol= "kuwait.html";
}
redirectTo(lol);
}
function redirectTo(location)
{
window.location.href =location;
}
我如何使用IntelXDK使用此代码,因为intelxdk使用不同的方法来保存cookie。请帮助,因为我是intelxdk的新手
下面是链接:
https://github.com/01org/cordova-plugin-intel-xdk-cache#removecookie