js编程思路--给网站定义一个全局的js对象,放到window对象中

if (typeof G === "undefined") {

    var G = window.G = {}

} 

定义一个全部局变量G,用来存放各个页面的初始化值,然后在各个页面顶端检查这个值是否初始化,如果没,则构建

或者:var G = window.G || {};

 

类似:

var jdpts = new Object(); jdpts._st = new Date().getTime();
window.pageConfig = {

compatible: true,

product: {

skuid: 722944,

name: '\u006c\u0061\u0074\u0069\u0074\u0020\u9ad8\u6863\u5c3c\u9f99\u914d\u771f\u76ae\u624b\u633d\u888b\u0020\u9ed1\u8272',

skuidkey:'19595C4D0862B0B5B684642B68D7FBFA',

href: 'http://www.360buy.com/product/722944.html',

src: 'g9/M03/0D/1C/rBEHaVCaQqoIAAAAAAE28iD_NIAAACtkgBv0rgAATcK056.jpg',

cat: [1672,2576,1455],

brand: 15138,

tips: false,

type: 2

}

};

 

你可能感兴趣的:(window)