现在的位置: 首页 > 综合 > 正文

常用JS。规范化。

2012年01月14日 ⁄ 综合 ⁄ 共 4867字 ⁄ 字号 评论关闭
var Flash = 
{
    Write : 
function(path,height,width,loop,param) 
    
{
        document.write ('
<OBJECT id="myFlashMovie" codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"');
        document.write ('height
="' + height + '" width="' + width + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" VIEWASTEXT>');
        document.write ('
<PARAM NAME="_cx" VALUE="14684">');
        document.write ('
<PARAM NAME="_cy" VALUE="5953">');
        Flash.WriteParam(param);    
        document.write ('
<PARAM NAME="Movie" VALUE="' + path + '">');
        document.write ('
<PARAM NAME="Src" VALUE="' + path + '">');
        document.write ('
<PARAM NAME="WMode" VALUE="Window">');
        document.write ('
<PARAM NAME="Play" VALUE="-1">');
        document.write ('
<PARAM NAME="Loop" VALUE="' + ((loop == null) ? -1 : loop)  + '">');
        document.write ('
<PARAM NAME="Quality" VALUE="High">');
        document.write ('
<PARAM NAME="SAlign" VALUE="">');
        document.write ('
<PARAM NAME="Menu" VALUE="-1">');
        document.write ('
<PARAM NAME="Base" VALUE="">');
        document.write ('
<PARAM NAME="AllowScriptAccess" VALUE="">');
        document.write ('
<PARAM NAME="Scale" VALUE="ShowAll">');
        document.write ('
<PARAM NAME="DeviceFont" VALUE="0">');
        document.write ('
<PARAM NAME="EmbedMovie" VALUE="0">');
        document.write ('
<PARAM NAME="BGColor" VALUE="">');
        document.write ('
<PARAM NAME="SWRemote" VALUE="">');
        document.write ('
<PARAM NAME="MovieData" VALUE="">');
        document.write ('
<PARAM NAME="SeamlessTabbing" VALUE="1">');
        document.write ('
<PARAM NAME="Profile" VALUE="0">');
        document.write ('
<PARAM NAME="ProfileAddress" VALUE="">');
        document.write ('
<PARAM NAME="ProfilePort" VALUE="0">');
        document.write ('
<embed src="' + path + '" swliveconnect="true" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" ');
        Flash.WriteEmbedParam(param);    
        document.write ('type
="application/x-shockwave-flash" height="' + height + '" width="' + width + '" name="myFlashMovie">');
        document.write ('
</embed>');
        document.write ('
</OBJECT>');
    }
,
    WriteParam : 
function(param)
    
{
        
if (param == null){
            document.write ('
<PARAM NAME="FlashVars" VALUE="">');
        }

        
else{
            document.write ('
<PARAM NAME="FlashVars" value="' + param.Name + '=' +     param.Value + '">');    
        }

    }
,
    WriteEmbedParam : 
function(param)
    
{
        
if (param == nullreturn;
        document.write ('FlashVars
="' + param.Name + '=' +     param.Value + '"');
    }

}

使用方法:
Flash.Write('/Images/Default/Flash/sports2.swf',225,555);

向上动感滚动文本代码。

var Site = 
{  
    IsIE : 
function()
    
{
        
return (window.navigator.userAgent.indexOf("MSIE"> 0);
    }
,
    AttachEvent : 
function(obj, eventName, delegate) 
    
{
        
if  (typeof( obj.addEventListener ) != 'undefined' ) 
        
{
            obj.addEventListener(Site.GetEventName(eventName),delegate,
false);
        }
 
        
else {
            obj.attachEvent(eventName,delegate);
        }

    }
,
    DetachEvent : 
function(obj,eventName,delegate)
    
{
        
if (obj.removeEventListener) {
            obj.removeEventListener(eventName,delegate, 
true);
        }

        
else if (obj.detachEvent) {
            obj.detachEvent(eventName,delegate);
        }

    }
,
    GetEventName : 
function (name)
    
{
        
return (name.indexOf('on') == 0? name.substring(2,name.length) : name;
    }
,
    SelectInitInput : 
function (name)
    
{
        Site.AttachEvent(window,'onload',
new Function('Site.SelectInput("' + name + '")'));
    }
,
    SelectInput : 
function (name)
    
{
        
var input = document.getElementById(name);
        input.select();input.focus();
    }
,
    SrcElement : 
function(evt)
    
{
        
return (window.event) ? event.srcElement : evt.target;
    }
,
    IsClickedEnter : 
function(evt)
    
{
        
var keycode = (window.event) ? window.event.keyCode : evt.which;
        
return (keycode == 13);
    }
,
    ClickedEnter : 
function(evt,enterElemId)
    
{
        
if (Site.IsClickedEnter(evt)){
            document.getElementById(enterElemId).click();
            
return false;
        }

        
return true;
    }
,
    WriteHTML : 
function (str)
    
{
        
for(i = 0 ; i < str.length ; i++){
            document.write(String.fromCharCode(
4^str.charCodeAt(i)));
        }

    }
,
    HandleErrorGlobal : 
function(strErrorMsg,strUrl,iLineNumber)
    
{
        window.status 
= strErrorMsg + ': Line:' + iLineNumber;
        
return true;
    }

}

window.onerror 
= Site.HandleErrorGlobal;

使用方法:
<span id="rot45638" style="height:80px;width:130px;"></span>

<script>var rot45638obj = new Rotator("rot45638",10,80,5000);Site.AttachEvent(window,"onload",new Function('rot45638obj.Init()'));</script>

完整JS:
http://files.cnblogs.com/raylynn/Site.js
http://files.cnblogs.com/raylynn/Flash.js

抱歉!评论已关闭.