ÍøÂçѧԺ w3popÉçÇø ÍøÂç×ÊÔ´ ITÐÂÎÅ

w3pop.com :: ÍøÂçѧԺ :: HTML DOM :: HTML DOM srcÊôÐÔ

»áÔ±µÇ½

ÕʺÅ

ÃÜÂë

»Ø´ð

¼ÇסÃÜÂë

Íü¼ÇÃÜÂë? ×¢²á

HTML DOM srcÊôÐÔ


×÷Õß:w3pop.com ·­Òë/ÕûÀí:w3pop.com ·¢²¼:2007-04-28 ä¯ÀÀ:1826 :: ::

The src property sets or returns the URL of the document that should be loaded into the frame.
srcÊôÐÔ¿ÉÒÔÉèÖûò·µ»ØÓ¦¼ÓÔØ½ø¿ò¼ÜÀïµÄÎĵµURL

Syntax
Óï·¨

frameObject.src=URL


Example
¾ÙÀý

In our example we will first create an HTML document containing a frameset with two columns. Each column is set to 50% of the browser window:
¾ÙÀýÖÐÎÒÃǽ¨Á¢ÁËÒ»¸ö°üº¬Á½¸öÁеĿò¼ÜHTMLÎĵµ£¬Ã¿¸öÁеĿí¶ÈΪÕû¸öä¯ÀÀÆ÷´°¿Ú×ܶζȵÄ50%:

<html>
  <frameset cols="50%,50%">
    <frame id="lFrame" src="frame_src.htm">
    <frame id="rFrame" src="frame_a.htm">
  </frameset>
</html>

The HTML document "frame_src.htm" is put into the first column, and the HTML document "frame_a.htm" is put into the second column.
"frame_src.htm"·ÅÖÃÔÚµÚÒ»¸öÁÐÖУ¬"frame_a.htm"ÔòÔÚµÚ¶þ¸öÁÐ

The source of "frame_src.htm" is as follows:
"frame_src.htm"µÄ´úÂëÈçÏ£º

<html>
<head>
<script type="text/javascript">
function newSrc()
{
parent.document.getElementById("lFrame").src="http://w3schools.com"
parent.document.getElementById("rFrame").src="http://google.com"
}
</script>
</head>
<body>
<form>
<input type="button" onclick="newSrc()"
value="Change frame source" />
</form>
</body>
</html>


Try-It-Yourself Demos
³¢ÊÔÓëÑÝʾ

Change the source of two frames
¸Ä±äÁ½¸ö¿ò¼ÜµÄÀ´Ô´µØÖ·

ÆÀÂÛ (0) All