;(function( $ ){
$.baiduDemo={
random : function () {
var tmp=Math.random()*10000;
return tmp;
},
getCtx : function () {
var obj=$("meta[name='company']");
var content=obj.attr("content");
if(!content || content==undefined || content=="" ){
console.error("getCtx() company is null. company="+company);
}
return content;
},
toRedirectURL : function () {
var ss=this.random();
var url=$.baiduDemo.getCtx() +"/link/toRedirect.htm?pp="+ss;
return url;
},
toMobileUI : function () {
var ss=this.random();
var url=$.baiduDemo.getCtx() +"/user/uMobileUI.htm";
return url;
},
indexURL : function () {
var ss=this.random();
var url=$.baiduDemo.getCtx() +"/index.htm?pp="+ss;
return url;
},
indexeErrorURL : function () {
var errormsg="#stopback";
var url=$.baiduDemo.indexURL()+errormsg;
return url;
},
webStopBackOnThisUI : function () {
var indexurl=document.location.href;
var _indexurl_1="";
var _indexurl_2="";
var errormsg="#errormsg";
var num=indexurl.indexOf(errormsg);
if(num==-1){
_indexurl_1=indexurl;
_indexurl_2=indexurl+errormsg;
}else{
_indexurl_1=indexurl.substring(0,num);
_indexurl_2=_indexurl_1+errormsg;
}
console.log("_indexurl_1 = "+_indexurl_1);
console.log("_indexurl_2 = "+_indexurl_2);
history.replaceState({goo:"stopback"},document.title,_indexurl_1);
history.pushState({goo:""},document.title,_indexurl_2);
window.addEventListener("popstate", function(e){
var state=history.state;
var is_stopback=(state && state.goo=="stopback");
console.log("state = "+state+" , is_stopback= "+is_stopback);
if(is_stopback){
location.href=_indexurl_1;
}
});
},
webStopBack : function () {
history.replaceState({goo:"stopback"},document.title,$.baiduDemo.indexURL());
history.pushState({goo:""},document.title,$.baiduDemo.indexeErrorURL());
window.addEventListener("popstate", function(e){
var state=history.state;
var is_stopback=(state && state.goo=="stopback");
console.log("state = "+state+" , is_stopback= "+is_stopback);
if(is_stopback){
location.href=$.baiduDemo.indexURL();
}
});
},
webStopBackIndex : function () {
var state=history.state;
var is_stopback_1=(state && state.goo=="stopback");
console.log("is_stopback_1 = "+is_stopback_1);
if(is_stopback_1){
history.replaceState({goo:"stopback"},document.title,$.baiduDemo.indexURL());
history.pushState({goo:""},document.title,$.baiduDemo.indexeErrorURL());
}
window.addEventListener("popstate", function(e){
var state=history.state;
var is_stopback=(state && state.goo=="stopback");
console.log("state = "+state+" , is_stopback= "+is_stopback);
if(is_stopback){
location.href=$.baiduDemo.indexURL();
}
});
}
};
})( jQuery );