js高级编程笔记3

字符串对象

1.charAt(index)从字符串中返回一个字符

2.string.toUpperCase()/string.toLowerCase()字符串大/小写转换

3.锚点(Anchor)相信很多人都不陌生,它方便访问者在页面的不同位置快速跳转,直接找到自己感兴趣的内容,如果说 RSS 是整个网站的摘要,那锚点就是一个页面的摘要,通常一个页面内容很多的时候,都会用锚点来定位

数学对象

1.Math.abs(a) 绝对值

2.Math.max(arg2,arg3)/Math.min(arg1,arg2)取两个参数的最大/小值

3.Math.round(arg1) 四舍五入最近的一个整数

4.Math.random() 产生0到1之间的随机数,例:

function showXinnianTip() {
            var XinCardList = [
        { cardName: "好礼都送你",img:"http://images.139cm.com/cximages/card/FlashCard/g551pjcn.jpg", swf: "http://images.139cm.com/cximages/card/FlashCard/3sxoeoo9.swf", text: "钟声是我的问候\r\n歌声是我的祝福\r\n雪花是我的贺卡\r\n美酒是我的飞吻\r\n清风是我的拥抱\r\n快乐是我的礼物\r\n统统都送给你\r\n祝你元旦快乐\r\n" },
        { cardName: "元旦送祝福",img:"http://images.139cm.com/cximages/card/FlashCard/atcmjpeq.jpg",  swf: "http://images.139cm.com/cximages/card/FlashCard/atcmjpeq.swf", text: "送你一份100%纯情奶糖\r\n成分=真心+思念+快乐\r\n有效期=一生\r\n营养=温馨+幸福+感动\r\n制造商:真心朋友\r\n祝你元旦快乐,万事如意\r\n" },
        { cardName: "迎元旦",img:"http://images.139cm.com/cximages/card/FlashCard/vqkabd4j.jpg", swf: "http://images.139cm.com/cximages/card/FlashCard/oja3qn01.swf", text: "我手摘一弯月牙\r\n头顶两颗星辰\r\n眼含三色秋波\r\n口叼九朵玫瑰\r\n脚踏十瑞祥云\r\n以闪电般的速度来到你的面前\r\n元旦快乐\r\n" },
        { cardName: "元旦小游戏",img:"http://images.139cm.com/cximages/card/FlashCard/u8rgc1ol.jpg", swf: "http://images.139cm.com/cximages/card/FlashCard/fr817lfj.swf", text: "请用一秒钟忘记烦恼\r\n用一分钟想想新年\r\n用一小时与爱人度过\r\n用一年来体会生活\r\n在新旧交替之际\r\n让这份快乐伴你迎接新年\r\n元旦快乐!\r\n" },
        { cardName: "新年新气象",img:"http://images.139cm.com/cximages/card/FlashCard/4ls4dg9o.jpg", swf: "http://images.139cm.com/cximages/card/FlashCard/nlolixnu.swf", text: "愿新的一年里\r\n你位高权重责任轻\r\n钱多事少离家近\r\n每日睡到大天亮\r\n工资领到手抽筋\r\n手下花钱你收礼\r\n别人加班你加薪\r\n元旦快乐\r\n" },
        { cardName: "快乐元旦",img:"http://images.139cm.com/cximages/card/FlashCard/2cspfmg5.jpg", swf: "http://images.139cm.com/cximages/card/FlashCard/9k3x0ckn.swf", text: "祝你每天的心情充满新鲜\r\n所有的心愿都会顺利实现\r\n烦恼全被爆竹炸开\r\n快乐幸福永驻心间\r\n元旦快乐!\r\n" },
        { cardName: "新年快乐",img:"http://images.139cm.com/cximages/card/FlashCard/yvioinj8.jpg", swf: "http://images.139cm.com/cximages/card/FlashCard/hvf7n5xe.swf", text: "岁月可以褪去记忆\r\n却褪不去我们一路留下的欢声笑语\r\n这一刻有我最深的思念\r\n让云捎去满心的祝福\r\n点缀你甜蜜的梦\r\n愿你拥有一个幸福快乐的新年\r\n" },
        { cardName: "新春伊始",img:"http://images.139cm.com/cximages/card/FlashCard/3fgrb66d.jpg", swf: "http://images.139cm.com/cximages/card/FlashCard/chh83ohu.swf", text: "新年的钟声\r\n敲响你心中的音符\r\n幸运与平安\r\n如春天的脚步紧紧相随\r\n元旦快乐\r\n" }
        ]
            zfServer.zfType = main_ext_Message.yd_zfType;
            zfServer.materId = 383;
            var cardArrLen = XinCardList.length;
            var currentRnd = Math.round(Math.random() * 10) % cardArrLen;

            zfServer.strCardZf = XinCardList[currentRnd].text;
            zfServer.strCardSwf = XinCardList[currentRnd].swf;
            zfServer.cardName = XinCardList[currentRnd].cardName;
            zfServer.strCardP = XinCardList[currentRnd].img;            
            
            zfServer.strSourceSugject = main_ext_Message.yd_strSourceSugject.format(zfServer.cardName);
            zfServer.ownh = main_ext_Message.yd_ownh;
            zfServer.ownp = main_ext_Message.yd_ownp.format(zfServer.cardName);
            zfServer.bmes = main_ext_Message.yd_behavior;
            zfServer.ShowZfCard("" + main_ext_Message.yd_zfType + "贺卡", 540, 420); //贺卡呈现


            var checkboxList = $("#moreCardMail input[@type=checkbox]");
            checkboxList.add("#sAllCardMail").click(function() {
                updateSelectCount();
                //$("#moreCardMail input[@type=checkbox]").
            })

            updateSelectCount();

            function updateSelectCount() {
                var selectedCount = 0;
                checkboxList.each(function() {
                    if (this.checked) {
                        selectedCount++;
                    }
                })

                $("#receiveNum").html(selectedCount.toString());
            }

            $("#changeCard").show().click(function() {
                //document.getElementById("flashCard").src="http://images.139cm.com/cximages/card/FlashCard/oja3qn01.swf";

                var nextRnd = Math.round(Math.random() * 10) % cardArrLen; //下一个随机数

                if (nextRnd == currentRnd) {   //防止下一个随机数和当前随机数相同
                    if (nextRnd == cardArrLen - 1) {
                        nextRnd = 0;
                    } else {
                        nextRnd += 1;
                    }
                }
                //alert(currentRnd+","+nextRnd);
                currentRnd = nextRnd; //置为当前随机数
                if (!zfServer.isOwn) {
                    $("#lblCardName").text(XinCardList[currentRnd].cardName);
                } else {
                    $("#lblOwnCardName").text(XinCardList[currentRnd].cardName);
                }

                var nextElem = $("#flashCard").next(); //保存下一节点的引用
                $("#flashCard").remove(); //删除节点
                nextElem.before("<embed id='flashCard' width='200' height='180' style='border: 1px solid green; width: 200px; margin-right: 5px; height: 180px; float: left;' src='"
                + XinCardList[nextRnd].swf
                + "' type='application/x-shockwave-flash'>");


                /*window.setInterval(function(){
                $("#changeCard").text($("#flashCard")[0].PercentLoaded());
                },100);*/

                $("#taZf")[0].value = XinCardList[nextRnd].text;

                zfServer.strCardZf = XinCardList[currentRnd].text; //切换变量
                zfServer.strCardSwf = XinCardList[currentRnd].swf; //切换变量
                zfServer.cardName = XinCardList[currentRnd].cardName; //切换变量
                zfServer.strCardP = XinCardList[currentRnd].img;
                zfServer.strSourceSugject = main_ext_Message.yd_strSourceSugject.format(zfServer.cardName);
                zfServer.ownp = main_ext_Message.yd_ownp.format(zfServer.cardName);
            });
        }

 

 

 


 


 

你可能感兴趣的:(编程)