JS¼¼Êõ

JavascriptË¢ÐÂÒ³µÄ·½·¨»ã×Ü

×ÖºÅ+ ×÷Õߣº À´Ô´£º    2014-11-17 20:00 ÎÒÒªÆÀÂÛ( )

JavascriptË¢ÐÂÒ³µÄ·½·¨»ã×Ü,ÔĶÁJavascriptË¢ÐÂÒ³µÄ·½·¨»ã×Ü,ÏÈÀ´¿´Ò»¸ö¼òµ¥µÄÀý×Ó£ºÏÂÃæÒÔÈý¸öÒ³Ãæ·Ö±ðÃüÃûΪframe.html¡¢top.html¡¢bottom.htmlΪÀýÀ´¾ßÌå˵Ã÷ÈçºÎ×ö¡£ frame.html ÓÉÉÏ(top.html)ÏÂ(bottom.html)Á½¸öÒ³Ãæ×é³É£¬´úÂëÈçÏ£º!DOCTYPE HTML PU

ÏÈÀ´¿´Ò»¸ö¼òµ¥µÄÀý×Ó£º
ÏÂÃæÒÔÈý¸öÒ³Ãæ·Ö±ðÃüÃûΪframe.html¡¢top.html¡¢bottom.htmlΪÀýÀ´¾ßÌå˵Ã÷ÈçºÎ×ö¡£

frame.html ÓÉÉÏ(top.html)ÏÂ(bottom.html)Á½¸öÒ³Ãæ×é³É£¬´úÂëÈçÏ£º
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> frame </TITLE>
</HEAD>
<frameset rows="50%,50%">
<frame name=top  src="top.html">
<frame name=bottom  src="bottom.html">
</frameset>
</HTML>

ÏÖÔÚ¼ÙÉètop.html (¼´ÉÏÃæµÄÒ³Ãæ) ÓÐÆ߸öbuttonÀ´ÊµÏÖ¶Ôbottom.html (¼´ÏÂÃæµÄÒ³Ãæ) µÄˢУ¬¿ÉÒÔÓÃÒÔÏÂÆßÖÖÓï¾ä£¬ÄĸöºÃÓÃ×Ô¼º¿´×Å°ìÁË¡£

Óï¾ä1. window.parent.frames[1].location.reload();
Óï¾ä2. window.parent.frames.bottom.location.reload();
Óï¾ä3. window.parent.frames["bottom"].location.reload();
Óï¾ä4. window.parent.frames.item(1).location.reload();
Óï¾ä5. window.parent.frames.item('bottom').location.reload();
Óï¾ä6. window.parent.bottom.location.reload();
Óï¾ä7. window.parent['bottom'].location.reload();

top.html Ò³ÃæµÄ´úÂëÈçÏ£º

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> top.html </TITLE>
 </HEAD>
<BODY>
<input type=button value="Ë¢ÐÂ1" onclick="window.parent.frames[1].location.reload()"><br>
<input type=button value="Ë¢ÐÂ2" onclick="window.parent.frames.bottom.location.reload()"><br>
<input type=button value="Ë¢ÐÂ3" onclick="window.parent.frames['bottom'].location.reload()"><br>
<input type=button value="Ë¢ÐÂ4" onclick="window.parent.frames.item(1).location.reload()"><br>
<input type=button value="Ë¢ÐÂ5" onclick="window.parent.frames.item('bottom').location.reload()"><br>
<input type=button value="Ë¢ÐÂ6" onclick="window.parent.bottom.location.reload()"><br>
<input type=button value="Ë¢ÐÂ7" onclick="window.parent['bottom'].location.reload()"><br>
</BODY>
</HTML>
ÏÂÃæÊÇbottom.htmlÒ³ÃæÔ´´úÂ룬ΪÁËÖ¤Ã÷Ï·½Ò³ÃæµÄÈ·±»Ë¢ÐÂÁË£¬ÔÚ×°ÔØÍêÒ³Ã浯³öÒ»¸ö¶Ô»°¿ò¡£

bottom.html Ò³ÃæµÄ´úÂëÈçÏ£º
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> bottom.html </TITLE>
 </HEAD>
<BODY onload="alert('ÎÒ±»¼ÓÔØÁË£¡')">
<h1>This is the content in bottom.html.</h1>
</BODY>
</HTML>


½âÊÍһϣº
1.windowÖ¸´úµÄÊǵ±Ç°Ò³Ã棬ÀýÈç¶ÔÓÚ´ËÀýËüÖ¸µÄÊÇtop.htmlÒ³Ãæ¡£
2.parentÖ¸µÄÊǵ±Ç°Ò³ÃæµÄ¸¸Ò³Ã棬Ҳ¾ÍÊÇ°üº¬ËüµÄ¿ò¼ÜÒ³Ãæ¡£ÀýÈç¶ÔÓÚ´ËÀýËüÖ¸µÄÊÇframedemo.html¡£
3.framesÊÇwindow¶ÔÏó£¬ÊÇÒ»¸öÊý×é¡£´ú±íןÿò¼ÜÄÚËùÓÐ×ÓÒ³Ãæ¡£
4.itemÊÇ·½·¨¡£·µ»ØÊý×éÀïÃæµÄÔªËØ¡£
5.Èç¹û×ÓÒ³ÃæÒ²ÊǸö¿ò¼ÜÒ³Ã棬ÀïÃ滹ÊÇÆäËüµÄ×ÓÒ³Ã棬ÄÇôÉÏÃæµÄÓÐЩ·½·¨¿ÉÄܲ»ÐС£

¸½£º
JavascriptË¢ÐÂÒ³ÃæµÄ¼¸ÖÖ·½·¨£º
1    history.go(0)
2    location.reload()
3    location=location
4    location.assign(location)
5    document.execCommand('Refresh')
6    window.navigate(location)
7    location.replace(location)
8    document.URL=location.href


×Ô¶¯Ë¢ÐÂÒ³ÃæµÄ·½·¨:
1.Ò³Ãæ×Ô¶¯Ë¢Ð£º°ÑÈçÏ´úÂë¼ÓÈë<head>ÇøÓòÖÐ
<meta http-equiv="refresh" content="20">
ÆäÖÐ20ָÿ¸ô20ÃëË¢ÐÂÒ»´ÎÒ³Ãæ.

2.Ò³Ãæ×Ô¶¯Ìøת£º°ÑÈçÏ´úÂë¼ÓÈë<head>ÇøÓòÖÐ
<meta http-equiv="refresh" content="20;url=http://www.wyxg.com">
ÆäÖÐ20Ö¸¸ô20ÃëºóÌøתµ½Ò³Ãæ

3.Ò³Ãæ×Ô¶¯Ë¢ÐÂjs°æ
<script language="JavaScript">
function myrefresh()
{
       window.location.reload();
}
setTimeout('myrefresh()',1000); //Ö¸¶¨1ÃëË¢ÐÂÒ»´Î
</script>

ASP.NETÈçºÎÊä³öˢи¸´°¿Ú½Å±¾Óï¾ä
1.   this.response.write("<script>opener.location.reload();</script>"); 

2.   this.response.write("<script>opener.window.location.href = opener.window.location.href;</script>");  

3.   Response.Write("<script language=javascript>opener.window.navigate(''ÄãҪˢеÄÒ³.asp'');</script>")


JSˢпò¼ÜµÄ½Å±¾Óï¾ä

//ÈçºÎˢаüº¬¸Ã¿ò¼ÜµÄÒ³ÃæÓà 
<script language=JavaScript>
   parent.location.reload();
</script>  


//×Ó´°¿Úˢи¸´°¿Ú
<script language=JavaScript>
    self.opener.location.reload();
</script>
(¡¡»ò¡¡<a href="javascript:opener.location.reload()">Ë¢ÐÂ</a>   )

//ÈçºÎË¢ÐÂÁíÒ»¸ö¿ò¼ÜµÄÒ³ÃæÓà 
<script language=JavaScript>
   parent.ÁíÒ»FrameID.location.reload();
</script>

Èç¹ûÏë¹Ø±Õ´°¿ÚʱˢлòÕßÏ뿪´°Ê±Ë¢ÐµĻ°£¬ÔÚ<body>Öе÷ÓÃÒÔÏÂÓï¾ä¼´¿É¡£

<body onload="opener.location.reload()"> ¿ª´°Ê±Ë¢ÐÂ
<body onUnload="opener.location.reload()"> ¹Ø±ÕʱˢÐÂ

<script language="javascript">
window.opener.document.location.reload()
</script>

¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • ѧϰJavaScriptÖ®this,call,apply

    ѧϰJavaScript֮this,call,apply

    2016-01-28 20:45

  • Áã»ù´¡ÈëÃÅѧϰPython£¨10£©£ºº¯Êý - qq_33256568µÄ²©¿Í - ²©¿ÍƵµÀ - CSDN.NET qq_3

    Áã»ù´¡ÈëÃÅѧϰPython£¨10£©£ºº¯Êý - qq_33256568µÄ²©¿Í - ²©¿ÍƵµÀ

    2015-12-15 09:04

  • ¡¾JavaScript.2¡¿±æÎöTypeof²Ù×÷·û×÷Óã¬ÂÞÁÐJSÎå´óÊý¾ÝÀàÐÍÕóÈÝ - Ã϶«»Ô ÀÈ·»Ê¦·¶Ñ§ÔºÐÅÏ¢¼¼ÊõÌá¸ß°à

    ¡¾JavaScript.2¡¿±æÎöTypeof²Ù×÷·û×÷Óã¬ÂÞÁÐJSÎå´óÊý¾ÝÀàÐÍÕóÈÝ -

    2015-12-15 09:00

  • ͼÏñ´¦ÀíÖеÄÊýѧԭÀíÏê½â19¡ª¡ªº¯ÊýµÄ¼«ÏÞ - °×Âí¸º½ðÄרÀ¸ - ²©¿ÍƵµÀ - CSDN.NET °×Âí¸º½ðÄרÀ¸

    ͼÏñ´¦ÀíÖеÄÊýѧԭÀíÏê½â19¡ª¡ªº¯ÊýµÄ¼«ÏÞ - °×Âí¸º½ðÄרÀ¸ - ²©

    2015-12-14 19:00

ÍøÓѵãÆÀ
È