HTML DOM src 属性

定义和用法

src 属性可设置或返回被载入 iframe 中的文档的 URL。

语法

  1. iframeObject.src=URL

实例

下面的例子可更改两个框架的源:

  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function changeSource()
  5. {
  6. document.getElementById("frame1").src="frame_c.htm"
  7. document.getElementById("frame2").src="frame_d.htm"
  8. }
  9. </script>
  10. </head>
  11. <body>
  12.  
  13. <iframe src="frame_a.htm" id="frame1"></iframe>
  14. <iframe src="frame_b.htm" id="frame2"></iframe>
  15. <br /><br />
  16. <input type="button" onclick="changeSource()"
  17. value="Change source of the two iframes" />
  18.  
  19. </body>
  20. </html>