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>
<
Ïà¹ØÎĵµ£º
¸ãÁË´ó°ëÌ죬×ÜËãŪÃ÷°×ÁËΪºÎÓÃdocument.body.clientHeight£¬document.body.offsetHeight¶¼Ã»Óаì
·¨»ñÈ¡ÍøÒ³¿É¼ûÇøÓòµÄÕýÈ·Öµ£¬ÔÀ´×ï¿ý»öÊ×ÊÇW3C¶¨ÒåµÄ±ê×¼£¡£¡ÔÚж¨Òå³öÀ´µÄ±ê×¼ÏÂ
document.documentElement.clientHeightÔÚIEºÍ»ðºüÀﶼÄÜ»ñÈ¡ÕýÈ·Öµ£¬ÏÂÃæһƪÎÄÕÂÏêϸ½éÉÜÁË»ñÈ¡¸÷ÖÖä¯ÀÀÆ÷¿É¼û
´°¿Ú´óСÕâ·½ÃæµÄ²î ......
Ïê̽TextRange¶ÔÏó--²éÕÒÓëÑ¡Ôñ
TextRange¶ÔÏóÊǶ¯Ì¬HTML(DHTML)µÄ¸ß¼¶ÌØÐÔ£¬Ê¹ÓÃËü¿ÉÒÔʵÏֺܶàºÍÎı¾ÓйصÄÈÎÎñ£¬ÀýÈçËÑË÷ºÍÑ¡ÔñÎı¾¡£Îı¾·¶Î§ÈÃÄú¿ÉÒÔÑ¡ÔñÐԵĽ«×Ö·û¡¢µ¥´ÊºÍ¾ä×Ó´ÓÎĵµÖÐÌôÑ¡³öÀ´¡£TextRange¶ÔÏóÊÇÔÚHTMLÎĵµ½«ÒªÏÔʾµÄÎı¾Á÷ÉϽ¨Á¢¿ªÊ¼ºÍ½áÊøλÖõijéÏó¶ÔÏó¡£
ÏÂÃæÊÇTextRangeµÄ³£ÓÃÊôÐÔÓë·½·¨£º
Ê ......
±íµ¥µÄ¿Í»§¶ËjavascriptÑéÖ¤Óи÷ÖÖ¸÷ÑùµÄд·¨£¬µÇ¼ΪformµÄonsubmitʼþ»òsubmit°´Å¤Ð´Ò»¸öº¯Êý¡£¶ÔÓÚС±íµ¥£¨Ö»ÓÐÒ»Á½¸ö±íµ¥ÓòµÄ±íµ¥£©¾Í²»±ØÔÙרÃÅÔÙÓÃjavascriptдһ¸öÑéÖ¤º¯ÊýÁË£¬Ö»ÐèÒªÔÚformµÄonsubmitʼþÀï¼ÓÉÏ£º
onsubmit=”return domainname.value==”?(alert(’ÇëÊäÈëËÑË÷ÄÚÈÝ’),false ......
var obj = new Object();
obj.name = "hello";
obj['name'] = "world";
alert(obj.name);
±»ÈËÎʵ½ÕâÑùÒ»¶Î´úÂ룬alertµÄ½á¹ûÓ¦¸ÃÊÇʲôÄØ£¿
Îһشð£ºhello #½á¹û´ó´íÌØ´í£¡
Ó¦¸ÃÊÇ“world”£¡£¡£¡
ÒòΪjsÊÇÒ»ÖÖËÉÉ¢ÀàÐ͵ÄÓïÑÔ£¬objËäÈ»±»ÉùÃ÷ÊÇÒ»¸ö¶ÔÏ󣬵«ÊÇ°ÑËüµ±³ÉÊý×éÀ´·ÃÎÊҲûʲô²»¿ÉÒÔ¡£
ËäÈ» ......
AA.HTM
-------------------------------------
<!--
showModalDialogº¯ÊýµÄʹÓà (ת)
±¾·¶Àý¿ÉÒÔʵÏÖµ¯³öÒ»¸öģ̬´°¿Ú£¬²¢ÑÝʾÁËÁ½ÖÖ½ÓÊպʹ«µÝ²ÎÊýµÄ·½·¨£¬Í¬Ê±¿ÉÒÔ½ÓÊÜģ̬´°¿Ú·µ»ØµÄ¶à¸ö±äÁ¿
-->
<html> &nbs ......