JavaScript³£Ó÷½·¨×ܽᗗÀûÓýű¾·â×°
ÀûÓýű¾·â×°£¬·½±ãʵÏÖÍøÕ¾Ðü¸¡¹ã¸æ
ÏÂÃæÊÇJS½Å±¾(floatdiv.js)
/*======================================================================
¸¡¶¯¿éÖ§³Ö½Å±¾
DESIGN BY : Åí¹ú»Ô
DATE: 2004-02-26
SITE: http://kacarton.yeah.net/
BLOG: http://blog.csdn.net/nhconch
EMAIL: kacarton@sohu.com
ÎÄÕÂΪ×÷ÕßÔ´´£¬×ªÔØÇ°ÇëÏÈÓë±¾ÈËÁªÏµ£¬×ªÔØÇë×¢Ã÷ÎÄÕ³ö´¦¡¢±£Áô×÷ÕßÐÅÏ¢£¬Ð»Ð»Ö§³Ö£¡
======================================================================*/
var alLeft = 0, alCenter = 1, alRight = 2; //ˮƽ¶ÔÆë·½Ê½
var alTop = 0, alMiddle = 1, alBottom = 2; //´¹Ö±¶ÔÆë·½Ê½
var f = new Array();
var cnt = 0;
function floatDiv(objId, align, vAlign, x, y, smooth)
{
/*¸¡¶¯¿é¶ÔÏó
Êý¾Ý½á¹¹£º
objId£º ¶ÔÏóID
align£º ˮƽ¶ÔÆë·½Ê½£¬Ã¶¾ÙÐÍ
vAlign£º´¹Ö±¶ÔÆë·½Ê½£¬Ã¶¾ÙÐÍÄÚÈÝ
x, y£º xy×ù±ê£¬ÕûÐÍ
smooth£ºÆ½»¬Òƶ¯£¬²¼¶ûÐÍ
*/
this.objId = objId;
this.align = align;
this.vAlign = vAlign;
this.x = x;
this.y = y;
this.smooth = smooth;
}
function addDiv(objId, align, vAlign, x, y, smooth)
{ //Ìí¼Ó¸¡¶¯¿é
f[cnt++] = new floatDiv(objId, align, vAlign, x, y, smooth);
}
function floatMove()
{ //ÖØÐ¶¨Î»¸÷¿éλÖÃ
var objX, objY;
if (document.all)
{
var d = document.body;
//status = "scrollLeft:"+f[0].objId.style.pixelTop+"| offsetWidth:"+d.offsetWidth;
for (var i=0; i<f.length; i++)
{
switch (f[i].align)
{
case alLeft : objX = d.scrollLeft + f[i].x; break;
case alCenter: objX = d.scrollLeft + Math.ceil((d.offsetWidth - f[i].objId.offsetWidth)/2) + f[i].x; break;
case alRight : objX = d.scrollLeft + d.offsetWidth - f[i].x - f[i].objId.offsetWidth - 20; break; //¼õ¹ö¶¯Ìõ20
}
switch (f[i].vAlign)
{
case alTop : objY = d.scrollTop + f[i].y; break;
case alMiddle: objY = d.scrollTop + Math.ceil((d.offsetHeight - f[i].objId.offsetHeight)/2) + f[i].y; break;
case alBottom: objY = d.scrollTop + d.offsetHeight - f[i].y - f[i].objId.offsetHeight; break;
}
if (f[i].smooth) smoothMove(f[i].objId, objX, objY);
else
{
f
Ïà¹ØÎĵµ£º
ÔÚjavascriptº¯ÊýÌåÄÚ£¬±êʶ·ûarguments¾ßÓÐÌØÊ⺬Òå¡£ËüÊǵ÷ÓöÔÏóµÄÒ»¸öÌØÊâÊôÐÔ£¬ÓÃÀ´ÒýÓÃArguments¶ÔÏó¡£Arugments¶ÔÏó¾ÍÏñÊý×飬עÒâÕâÀïÖ»ÊÇÏñ²¢²»Êǹþ¡£
javascriptº¯ÊýÌåÄÚ£¬argumentsÏñÊý×é(²¢²»ÊÇÕæµÄÊý×飬ÊÇÒ»¸öArguments¶ÔÏó£¬ÔÙ´ÎÇ¿µ÷)Ò»Ñù£¬ÓÐlengthÊôÐÔ£¬¿ÉÒÔ´ú±í´«¸øº¯ÊýµÄ²ÎÊýµÄ¸öÊý¡£
ÒýÓÃÒ»¸öÐÎʽ² ......
Definition and Usage
¶¨ÒåÓëÓ÷¨The constructor property is a reference to the function that created an object.
constructorÊôÐÔÊÇËù½¨Á¢¶ÔÏóµÄº¯Êý²Î¿¼Syntax
Óï·¨object.constructor
Example 1
¾ÙÀý
In this example we will show how to use the constructor property:
ÔÚÕâ¸ö¾ÙÀýÖÐÎÒÃǽ«Õ¹Ê¾ÈçºÎʹÓÃcons ......
1.document.write( " "); Êä³öÓï¾ä
2.JSÖеÄ×¢ÊÍΪ//
3.´«Í³µÄHTMLÎĵµË³ÐòÊÇ:document- >html- >(head,body)
4.Ò»¸öä¯ÀÀÆ÷´°¿ÚÖеÄDOM˳ÐòÊÇ:window- >(navigator,screen,history,location,document)
5.µÃµ½±íµ¥ÖÐÔªËØµÄÃû³ÆºÍÖµ:document.getElementById( "±íµ¥ÖÐÔªËØµÄID號 ").name(»òvalue)
6.Ò»¸ö ......
IE¿ÉÒÔµ÷Óãº
<script type="text/javascript">
// ˵Ã÷£º»ñÈ¡Ò³ÃæÉÏÑ¡ÖеÄÎÄ×Ö
// ÕûÀí£ºhttp://www.CodeBit.cn
function getSelectedText() {
if (window.getSelection) {
// This technique is the most likel ......
ÅжÏä¯ÀÀÆ÷ÀàÐÍ
<SCRIPT language=javascript>
if(navigator.appVersion.indexOf("MSIE 6.") != -1 ){
window.location = "111.htm" ;
}
</SCRIPT>
°´Å¥±³¾°Í¼Æ¬Ìæ»»
<input type=button style="background-image:url(a.gif)" value=test onmouseover="this.style.backgroundImage='url(b.gif ......