首页 > 代码库 > 灰姑娘专题总结

灰姑娘专题总结

http://cinderella.1905.com/

前两天加急做了一个专题,后来增改了不少东西,还是略吃力。

================================================    分割线    ===========================================================

1) 页面内添加如下代码,为学员的信息不包含排名。先追加

<script type="text/javascript">var SPECIALCONFIG = {    nav_tabname : index,    voteids : "321834318,321834321,321834332,321834333,321834338,321833823,321833824,321842611,321842613,321842616,321842617,321842618,321842620,321842624",    infos : {"321834318":{"id":321834318,"title":"\u9732\u897f\u00b7\u5b9d\u901a","url":"http:\/\/www.1905.com\/http:\/\/www.1905.com\/mdb\/star\/2700989\/","thumb":"http:\/\/image11.m1905.cn\/uploadfile\/2014\/1216\/20141216025708535339.jpg"},"321834321":{"id":321834321,"title":"\u4e9a\u5386\u5c71\u5fb7\u62c9\u00b7\u9053\u7075","url":"http:\/\/www.1905.com\/http:\/\/www.1905.com\/mdb\/star\/3042415\/","thumb":"http:\/\/image11.m1905.cn\/uploadfile\/2014\/1216\/20141216030224142148.jpg"},"321834332":{"id":321834332,"title":"\u4f0a\u6069\u00b7\u9ea6\u67ef\u8096\u6069","url":"http:\/\/www.1905.com\/http:\/\/www.1905.com\/mdb\/star\/1470642\/","thumb":"http:\/\/image11.m1905.cn\/uploadfile\/2014\/1216\/20141216031510179309.jpg"},"321834333":{"id":321834333,"title":"\u6734\u96c5\u82f1","url":"http:\/\/www.1905.com\/http:\/\/www.1905.com\/mdb\/star\/3042417\/","thumb":"http:\/\/image11.m1905.cn\/uploadfile\/2014\/1216\/20141216031527780475.jpg"},"321834338":{"id":321834338,"title":"\u5d14\u6b63\u5143","url":"http:\/\/www.1905.com\/http:\/\/www.1905.com\/mdb\/star\/3042418\/","thumb":"http:\/\/image11.m1905.cn\/uploadfile\/2014\/1216\/20141216032521520919.jpg"},"321833823":{"id":321833823,"title":"\u6734\u653f\u739f","url":"http:\/\/www.1905.com\/http:\/\/www.1905.com\/mdb\/star\/3042407\/","thumb":"http:\/\/image11.m1905.cn\/uploadfile\/2014\/1215\/20141215031653221905.jpg"},"321833824":{"id":321833824,"title":"\u91d1\u5ba5\u771f","url":"http:\/\/www.1905.com\/http:\/\/www.1905.com\/mdb\/star\/3042408\/","thumb":"http:\/\/image11.m1905.cn\/uploadfile\/2014\/1215\/20141215032147123433.jpg"},"321842611":{"id":321842611,"title":"\u5f20\u99a8\u5143","url":"http:\/\/www.1905.com\/http:\/\/www.1905.com\/mdb\/star\/3042353\/","thumb":"http:\/\/image11.m1905.cn\/uploadfile\/2014\/1211\/20141211034324770365.jpg"}        }};</script>

列表页执行js的时候会提示 SPECIALCONFIG 未定义,此时判断只有页面内有 SPECIALCONFIG 的时候出现了问题。

判断SPECIALCONFIG.length   结果 undefined

当不知道怎么判断的时候 可以typeof(SPECIALCONFIG)看下它是什么类型    输出 "object"  ,所以可以通过这点判断  

if(typeof(SPECIALCONFIG) == ‘object‘){

  执行响应操作;

}

2) js追加上面代码里面的信息到html的时候,需要for in遍历

for(var m in SPECIALCONFIG.infos){

}

3) 获取当前时间的方法

A)  new Date().getTime() 返回的是当前时间的毫秒数

B)  拼成201412231542这种格式的    

date.getFullYear().toString() + (date.getMonth()+1).toString() + date.getDate().toString() + date.getHours().toString() + date.getMinutes().toString();

     date.getFullYear()获取到的是数字 用加号不能直接拼接,只能转化为字符串进行拼接   toString()

 

灰姑娘专题总结