HTML DOM name 屬性
定義和用法
name 屬性可設置或返回存放窗口的名稱的一個字符串。
該名稱是在 open() 方法創(chuàng)建窗口時指定的或者使用一個 <frame> 標記的 name 屬性指定的。
窗口的名稱可以用作一個 <a> 或者 <form> 標記的 target 屬性的值。以這種方式使用 target 屬性聲明了超鏈接文檔或表單提交結(jié)果應該顯示于指定的窗口或框架中。
語法
window.name=name
實例
下面的例子可返回新窗口的名稱:
<html> <head> <script type="text/javascript"> function checkWin() { document.write(myWindow.name) } </script> </head> <body> <script type="text/javascript"> myWindow=window.open('','MyName','width=200,height=100') myWindow.document.write("This is 'myWindow'") </script> <input type="button" value="What's the name of 'myWindow'?" onclick="checkWin()"> </body> </html>