最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

摘自啟點的main.js

 更新時間:2008年04月20日 14:32:49   作者:  
來自啟點的js,主要包括字符串的trim,cookies設(shè)置等
String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, "");
}

String.prototype.len=function()
{
    return this.replace(/[^\x00-\xff]/g,'aa').length;


function StringBuilder(value)
{
    this.strings = new Array("");
    this.append(value);
}

// Appends the given value to the end of this instance.
StringBuilder.prototype.append = function (value)
{
    if (value)
    {
        this.strings.push(value);
    }
}

// Clears the string buffer
StringBuilder.prototype.clear = function ()
{
    this.strings.length = 1;
}

// Converts this instance to a String.
StringBuilder.prototype.toString = function ()
{
    return this.strings.join("");
}

//string format prototype
// sample: var test="my name is {0} {2} " ;
//              alert(test.format('liang','zhonghua');
  if (!String._FORMAT_SEPARATOR){
        String._FORMAT_SEPARATOR = String.fromCharCode(0x1f);
        String._FORMAT_ARGS_PATTERN = new RegExp('^[^' + String._FORMAT_SEPARATOR + ']*'
            + new Array(100).join('(?:.([^' + String._FORMAT_SEPARATOR + ']*))?'));
    }
    if (!String.format)
    {
        String.format = function (s){
            return Array.prototype.join.call(arguments, String._FORMAT_SEPARATOR).
                replace(String._FORMAT_ARGS_PATTERN, s);
        }
    }
    if (!''.format)
    {
    String.prototype.format = function (){
        return (String._FORMAT_SEPARATOR +
            Array.prototype.join.call(arguments, String._FORMAT_SEPARATOR)).
            replace(String._FORMAT_ARGS_PATTERN, this);
    }
}
//end string format

function checkLoginByCookie()
{
    var cookieId="AUTHTEST";
    if(window.location.href.toLowerCase().indexOf("qidian.com") > -1)
    {
        cookieId="cmfuToken";
    }

    if((GetCookie(cookieId)!=null && GetCookie(cookieId).length > 0 ))
    {
        return true;
    }
    else
    {
        if(GetCookie('cmfu_al') != null && GetCookie('cmfu_al').length > 0)
        {
            return true;
        }
    }
    return false;
}

function  getUrlParam(name)
{   
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)","i");   
    var r = window.location.search.substr(1).match(reg);   
    if (r!=null)  
    {
        return   unescape(r[2]);
    }
    else
    {  
        return   null;   
    }
}  

function $(objName)
{

    if(document.getElementById)
    {
        return document.getElementById(objName );
    }
    else if(document.layers)
    {
        return eval("document.layers['" + objName +"']");
    }
    else
    {
        return eval('document.all.' + objName);
    }
}

function DateAdd(BaseDate, interval, DatePart)
{
 var dateObj = new Date(BaseDate.replace("-",","));
 var millisecond=1;
 var second=millisecond*1000;
 var minute=second*60;
 var hour=minute*60;
 var day=hour*24;
 var year=day*365;

 var newDate;
 var dVal = new Date(dateObj)
 var dVal=dVal.valueOf();
 switch(DatePart)
 {
  case "ms": newDate=new Date(dVal+millisecond*interval); break;
  case "s": newDate=new Date(dVal+second*interval); break;
  case "mi": newDate=new Date(dVal+minute*interval); break;
  case "h": newDate=new Date(dVal+hour*interval); break;
  case "d": newDate=new Date(dVal+day*interval); break;
  case "y": newDate=new Date(dVal+year*interval); break;
  default: return escape("日期格式不對");
 }
 newDate = new Date(newDate);
 return newDate.getFullYear() + "-" + (newDate.getMonth() + 1) + "-" + newDate.getDate() ; 
}

//增加當(dāng)前日期的天數(shù)
Date.prototype.AddDays=function (interval)
{
     var dateObj = this;
 var millisecond=1;
 var second=millisecond*1000;
 var minute=second*60;
 var hour=minute*60;
 var day=hour*24;
 var year=day*365;

 var newDate;
 var dVal = new Date(dateObj)
 var dVal=dVal.valueOf();

  newDate=new Date(dVal+day*interval); 

 newDate = new Date(newDate);
 return newDate
}

function SetCookie(name, value)
{

var argv = SetCookie.arguments;

    var argc = SetCookie.arguments.length;

    var expires = (argc > 2) ? argv[2].toGMTString() : (new Date()).AddDays(30).toGMTString();;

    var path = (argc > 3) ? argv[3] : "/";

    var domain = (argc > 4) ? argv[4] : null;

    var secure = (argc > 5) ? argv[5] : false;

   
    var content = name + "=" + escape(value) + ";";
    if(expires != null)
    {
        content += " expires=" + expires + ";";
    }
    if(path != null)
    {
        content += " path=" + path + ";";
    }
    if(domain != null)
    {
        content += " domain=" + domain + ";";
    }

    
    document.cookie = content;


}

function GetCookie(cookieName) 
{
    var cookieString = document.cookie;

    var start = cookieString.indexOf(cookieName + '=');

    

    // 加上等號的原因是避免在某些 Cookie 的值里有
    // 與 cookieName 一樣的字符串。

    if (start == -1) // 找不到
    return null;

    start += cookieName.length + 1;
    var end = cookieString.indexOf(';', start);
    if (end == -1) return unescape(cookieString.substring(start));
    return unescape(cookieString.substring(start, end));
}


/*文本框得到焦點*/
function TextBoxOnFocus(txtControl,strDefaultText)
{
    if (txtControl.value==strDefaultText)
        txtControl.value="";
}
/*文本框失去焦點*/
function TextBoxOnBlur(txtControl,strDefaultText)
{
    if (txtControl.value.replace(/(^[\s]*)|([\s]*$)/g,"")=="")
        txtControl.value=strDefaultText;
}


/*功能:彈出群發(fā)消息窗口*/
function MultiSendWin(subject,content)
{
    var win =window.open(uploadURL+"?subject=" + subject + "&content=" +content,"","menubar=no,width=480,height=550,resizeable=no","");
    return false;
}


/*功能:彈出留言窗口
function SpaceSendMsg(toUserId)
{
    var win =window.open(spaceSendMsgURL+"?toUserId=" + toUserId,"","menubar=no,width=500,height=400,resizeable=no","");
    return false;
}
*/

function ShowServerMessage(result)
{
    eval(result.value);
}

//回車提交表單
function KeydownSubmitForm(btnId)
{
    var btn=document.getElementById(btnId);
    if (btn!=null&& event.keyCode== 13)
    {
         event.returnValue=false;
         event.keyCode=9;
         btn.click();  
    }  
}  

//ReadChapter -抵用券js
function MDown(Object){
    Obj=Object.id
    document.all(Obj).setCapture()
    pX=event.x-document.all(Obj).style.pixelLeft;
    pY=event.y-document.all(Obj).style.pixelTop;
}

function MMove(){
    if(Obj!=''){
        document.all(Obj).style.left=event.x-pX;
        document.all(Obj).style.top=event.y-pY;
    }
}

function MUp(){
    if(Obj!=''){
        document.all(Obj).releaseCapture();
        Obj='';
    }
}

//關(guān)閉抵用券信息
function LayerClose(divDiscount){
    document.getElementById(divDiscount).style.visibility="hidden";
}

//顯示抵用券信息
function LayerShow(divDiscount,discountPrize){
    var prizeUI = document.getElementById(divDiscount);
    prizeUI.style.left = screen.width-530;
    prizeUI.style.top = screen.Height - 480;
    prizeUI.style.visibility="visible";

    document.getElementById("lblPrize1").innerHTML=discountPrize;
    document.getElementById("lblPrize2").innerHTML=discountPrize;
    window.setInterval("LayerClose('" + divDiscount + "')",15000);
}

//幫助masterpage用
function HideMenu(menuid)
{
    var obj = document.getElementById(menuid);
    if(obj.style.display == "none")
    {
        obj.style.display = "";
    }
    else
    {
        obj.style.display = "none";
    }

    if(obj.style.display == "")
    {
        var tmpId = "M0";
        for(var i  = 1 ; i <= 9; i++)
        {
            var myid = tmpId + i;
            if(myid != menuid)
            {
                document.getElementById(myid).style.display = "none";
            }
        }
    }
}

/* div login */
function ShowLoginDiv()
{
    var builder = new StringBuilder();
    builder.append("<table border='0' cellpadding='0' cellspacing='0'>");
    builder.append("<tr class='TitleTR'>");
    builder.append("<td align='left'>");
    builder.append("登錄");
    builder.append("</td>");
    builder.append("<td align='right'>");
    builder.append("<span title='關(guān)閉' onclick='HideLoginMask();'>×</span>");
    builder.append("</td>");
    builder.append("</tr>");
    builder.append("<tr>");
    builder.append("<td colspan='2'>");
    builder.append("<iframe src='/DivUserLogin.aspx' width='225px' height='125px' name='loginFrame' ");//src=''
    builder.append("id='loginFrame' frameborder='0' scrolling='no'></iframe>");
    builder.append("</td>");
    builder.append("</tr>");
    builder.append("</table>");    
    //window.top.scrollTo(0,0);
    document.getElementById("DivMask").style.height=document.body.scrollHeight;
    document.getElementById("DivMask").style.width=document.body.scrollWidth;
    document.getElementById("DivMask").style.display = 'block';                
    document.getElementById("DivLogin").style.display = "block";
    document.getElementById("DivLogin").innerHTML = builder.toString();
    ScrollDiv();  
    window.onscroll=ScrollDiv;
    window.onresize=ScrollDiv;
    window.onload=ScrollDiv; 

function HideLoginMask()
{
    document.getElementById("DivMask").style.display="none";
    document.getElementById("DivLogin").style.display="none";
}        
/*隨屏幕滾動*/
function ScrollDiv()
{
  if($("DivLogin"))
  {
    document.getElementById("DivLogin").style.top=(document.body.scrollTop+
    (document.body.clientHeight-document.getElementById("DivLogin").offsetHeight)/2)+"px";

    document.getElementById("DivLogin").style.left=(document.documentElement.scrollLeft+
    (document.body.clientWidth-document.getElementById("DivLogin").offsetWidth)/2)+"px";

   }

  if($("AddMark"))
  {
//  if(!event )
//        return;

    $("AddMark").style.top=document.body.clientHeight + document.body.scrollTop-200
    $("AddMark").style.left=document.body.clientWidth-56;
     $("AddMark").style.display=''; 

   // (document.body.clientHeight-$("AddMark").offsetHeight)/2)+"px";
   if($("MonthVoteTip"))
   {
    //$("MonthVoteTip").style.top=document.body.scrollTop+document.body.clientHeight-$("MonthVoteTip").offsetHeight+"px";
   $("MonthVoteTip").style.top = getPosition($("AddMark")).y - $("AddMark").offsetHeight + "px";
   }
  }

}
function AutoScroll()
{

    window.onscroll=ScrollDiv;
    window.onresize=ScrollDiv;
   window.onload=ScrollDiv; 
}

function getPosition(el)
{
for (var lx=0,ly=0;el!=null;lx+=el.offsetLeft,ly+=el.offsetTop,el=el.offsetParent);
return {x:lx,y:ly}
}

/* 2007-11-28 XuJian */
//截取字符串 包含中文處理
//(串,長度,增加...)
function subString(str, len, hasDot)
{
    var newLength = 0;
    var newStr = "";
    var chineseRegex = /[^\x00-\xff]/g;
    var singleChar = "";
    var strLength = str.replace(chineseRegex,"**").length;
    for(var i = 0;i < strLength;i++)
    {
        singleChar = str.charAt(i).toString();
        if(singleChar.match(chineseRegex) != null)
        {
            newLength += 2;
        }    
        else
        {
            newLength++;
        }
        if(newLength > len)
        {
            break;
        }
        newStr += singleChar;
    }

    if(hasDot && strLength > len)
    {
        newStr += "...";
    }
    return newStr;
}

/* 2007-10-26 14:20 Get String Lenth(include chinese character) */
function GetStringLength(strObj)
{
    return strObj.replace(/[^\x00-\xff]/g,"**").length;
}

function addMark(title,url) {
try{
if (window.sidebar) { 
window.sidebar.addPanel(title, url,""); 
} else if( document.all ) {
window.external.AddFavorite( url, title);
} else if( window.opera && window.print ) {
return true;
}
}catch(e)
{
    alert("您的瀏覽器安全設(shè)置不允許該項操作")
}
}

相關(guān)文章

  • javascript 框架小結(jié) 個人工作經(jīng)驗

    javascript 框架小結(jié) 個人工作經(jīng)驗

    javascript 框架小結(jié) 個人工作經(jīng)驗,對于新手來說還是值得學(xué)習(xí)的。
    2009-06-06
  • 微信小程序 css使用技巧總結(jié)

    微信小程序 css使用技巧總結(jié)

    這篇文章主要介紹了微信小程序 css使用技巧總結(jié)的相關(guān)資料,需要的朋友可以參考下
    2017-01-01
  • TypeScript中的類

    TypeScript中的類

    這篇文章主要介紹了TypeScript中的類,類這個概念基本是所有面向?qū)ο缶幊陶Z言都具有一個概念,JavaScript中ES6?之前是沒有類這個概念,下面文章圍繞TypeScript類的相關(guān)資料展開內(nèi)容,需要的朋友可以參考一下
    2021-12-12
  • javascript的switch用法注意事項分析

    javascript的switch用法注意事項分析

    這篇文章主要介紹了javascript的switch用法注意事項,實例分析了switch語句進(jìn)行判定的原理與使用技巧,非常具有實用價值,需要的朋友可以參考下
    2015-02-02
  • JS面試必備之手寫call/apply/bind/new

    JS面試必備之手寫call/apply/bind/new

    在JavaScript中,call、apply、bind、new是Function對象自帶的三個方法,也是面試時??嫉闹R點,所以本文就來和大家講講如何手寫實現(xiàn)這四個方法吧
    2023-05-05
  • JavaScript實現(xiàn)定時隱藏與顯示圖片的方法

    JavaScript實現(xiàn)定時隱藏與顯示圖片的方法

    這篇文章主要介紹了JavaScript實現(xiàn)定時隱藏與顯示圖片的方法,可實現(xiàn)javascript定時關(guān)閉圖片的功能,涉及javascript針對頁面元素屬性定時操作的相關(guān)技巧,需要的朋友可以參考下
    2015-08-08
  • Jquery 常用方法一覽表(集合)

    Jquery 常用方法一覽表(集合)

    之前腳本之家發(fā)過相關(guān)的文章,這里又是一篇關(guān)于jquery常用方法的收集整理,我們給放到一起,學(xué)習(xí)jquery的朋友可以參考下。
    2010-03-03
  • 原生js實現(xiàn)自定義滾動條組件

    原生js實現(xiàn)自定義滾動條組件

    這篇文章主要為大家詳細(xì)介紹了原生js實現(xiàn)自定義滾動條組件的開發(fā),文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-01-01
  • javascript實現(xiàn)動態(tài)側(cè)邊欄代碼

    javascript實現(xiàn)動態(tài)側(cè)邊欄代碼

    這篇文章主要介紹了javascript實現(xiàn)動態(tài)側(cè)邊欄代碼,需要的朋友可以參考下
    2014-02-02
  • js實現(xiàn)input密碼框顯示/隱藏功能

    js實現(xiàn)input密碼框顯示/隱藏功能

    這篇文章主要為大家詳細(xì)介紹了js實現(xiàn)input密碼框顯示和隱藏功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-10-10

最新評論

任丘市| 涟水县| 青海省| 宝清县| 恩施市| 禄劝| 哈巴河县| 新平| 灵寿县| 长武县| 随州市| 子洲县| 普洱| 新干县| 高碑店市| 安义县| 水城县| 乌兰浩特市| 射阳县| 抚顺市| 宝坻区| 连山| 湘潭市| 凤阳县| 晋城| 古蔺县| 泰州市| 梧州市| 连山| 宝清县| 临汾市| 北碚区| 伊宁市| 汪清县| 荔浦县| 富源县| 山东省| 田东县| 三台县| 宜春市| 堆龙德庆县|