javascriptµ÷Óø¸´°¿ÚµÄº¯ÊýºÍ±äÁ¿
javascriptµ÷Óø¸´°¿ÚµÄº¯ÊýºÍ±äÁ¿
·¢²¼ÈÕÆÚ£º2008-05-28×î½ü¸üУº2008-05-28À´Ô´£ºBHCODE×÷Õߣº
web¿ª·¢µÄʱºò£¬ÓÐʱºòÐèҪʹÓÃÆäËûÒ³ÃæÉÏдºÃµÄjavasriptº¯Êý¡¢±äÁ¿¡£È絯³ö´°¿ÚÐèҪʹÓø¸´°¿ÚÖеĺ¯Êý£¬¿ò¼Ü1ÐèҪʹÓÿò¼Ü2Öеĺ¯Êý¡£
µ÷Óú¯Êý¡¢±äÁ¿µÄ·½·¨Ò»Ñù£¬¶¼ÊÇÐèÒªÊ×ÏÈ»ñµÃÄãÐèÒªµ÷Óõĺ¯ÊýËùÔÚµÄwindow¶ÔÏó£¬È»ºóͨ¹ýwindow.method()»òÕß window.variable À´µ÷Óá£
ÏÂÃæµÄʾÀýÑÝʾÁËÒ»¸öµ¯³ö´°¿ÚÈçºÎµ÷ÓÃÆ𸸴°¿ÚÖеķ½·¨ºÍ±äÁ¿¡£
¸¸´°¿Ú£º1.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>ÎÞ±êÌâÎĵµ</title>
<script type="text/javascript">
var theHelloStr = "Hello all.";
function sayHello()
{
alert("hello, method");
}
function openBtnClicked()
{
var newwin=window.open('2.html',"test","toolbar=no,location=no,top=100,left=100,directories=no,status=yes,menubar=no,scrollbars=yes,location=no,resizable=yes,width=300,height=200");
newwin.focus();
}
function sayHello2()
{
window.sayHello();
}
</script>
</head>
<body>
<input type="button" name="openBtn" value="´ò¿ª´°¿Ú" onclick="openBtnClicked()" />
</body>
</html>
µ¯³ö´°¿Ú£º2.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>ÎÞ±êÌâÎĵµ</title>
<script type="text/javascript">
function btn1Clicked()
{
window.opener.sayHello();
}
function btn2Clicked()
{
var helloMsg = window.opener.theHelloStr;
alert(helloMsg);
}
</script>
</head>
<
Ïà¹ØÎĵµ£º
Ïê̽TextRange¶ÔÏó--²éÕÒÓëÑ¡Ôñ
TextRange¶ÔÏóÊǶ¯Ì¬HTML(DHTML)µÄ¸ß¼¶ÌØÐÔ£¬Ê¹ÓÃËü¿ÉÒÔʵÏֺܶàºÍÎı¾ÓйصÄÈÎÎñ£¬ÀýÈçËÑË÷ºÍÑ¡ÔñÎı¾¡£Îı¾·¶Î§ÈÃÄú¿ÉÒÔÑ¡ÔñÐԵĽ«×Ö·û¡¢µ¥´ÊºÍ¾ä×Ó´ÓÎĵµÖÐÌôÑ¡³öÀ´¡£TextRange¶ÔÏóÊÇÔÚHTMLÎĵµ½«ÒªÏÔʾµÄÎı¾Á÷ÉϽ¨Á¢¿ªÊ¼ºÍ½áÊøλÖõijéÏó¶ÔÏó¡£
ÏÂÃæÊÇTextRangeµÄ³£ÓÃÊôÐÔÓë·½·¨£º
Ê ......
´´½¨Ò»¸öÈÕÆÚ¶ÔÏó£º
var objDate=new Date([arguments list]);
²ÎÊýÐÎʽÓÐÒÔÏ£µÖÖ£º
new Date("month dd,yyyy hh:mm:ss");
new Date("month dd,yyyy");
new Date(yyyy,mth,dd,hh,mm,ss);
new Date(yyyy,mth,dd);
new Date(ms); ......
var obj = new Object();
obj.name = "hello";
obj['name'] = "world";
alert(obj.name);
±»ÈËÎʵ½ÕâÑùÒ»¶Î´úÂ룬alertµÄ½á¹ûÓ¦¸ÃÊÇʲôÄØ£¿
Îһشð£ºhello #½á¹û´ó´íÌØ´í£¡
Ó¦¸ÃÊÇ“world”£¡£¡£¡
ÒòΪjsÊÇÒ»ÖÖËÉÉ¢ÀàÐ͵ÄÓïÑÔ£¬objËäÈ»±»ÉùÃ÷ÊÇÒ»¸ö¶ÔÏ󣬵«ÊÇ°ÑËüµ±³ÉÊý×éÀ´·ÃÎÊҲûʲô²»¿ÉÒÔ¡£
ËäÈ» ......
var myDate = new Date();
myDate.getYear(); //»ñÈ¡µ±Ç°Äê·Ý(2λ)
myDate.getFullYear(); //»ñÈ¡ÍêÕûµÄÄê·Ý(4λ,1970-????)
myDate.getMonth(); //»ñÈ¡µ±Ç°Ô·Ý(0-11,0´ú±í1ÔÂ)
myDate.getDate();   ......
AA.HTM
-------------------------------------
<!--
showModalDialogº¯ÊýµÄʹÓà (ת)
±¾·¶Àý¿ÉÒÔʵÏÖµ¯³öÒ»¸öģ̬´°¿Ú£¬²¢ÑÝʾÁËÁ½ÖÖ½ÓÊպʹ«µÝ²ÎÊýµÄ·½·¨£¬Í¬Ê±¿ÉÒÔ½ÓÊÜģ̬´°¿Ú·µ»ØµÄ¶à¸ö±äÁ¿
-->
<html> &nbs ......