window.open()中的name参数是什么

时间:2010-03-13 12:29:12

标签: javascript

请有人告诉我window.open()中的这个窗口名称是标题名称还是java脚本语言中的一些ID?

3 个答案:

答案 0 :(得分:4)

windowName

要给新窗口的名称。该名称可用于再次引用此窗口。

打开窗口后,你会想要用它做各种各样的事情,例如移动它然后你可以做

<html>
<head>
<title>Window Example</title>
</head>
<SCRIPT language="JavaScript1.2">
function poponload()
{
    testwindow= window.open ("", "mywindow");
    alert('I will move window to 0,0');
    testwindow.moveTo(0,0);
}
</SCRIPT>
<body onload="javascript: poponload()">
<H1>Window Example</H1>
</body>
</html> 

并且它的window title不同。

-source

答案 1 :(得分:2)

来自 MDC on window.open()

window.open(strUrl, strWindowName  [, strWindowFeatures]);
  

<强> strWindowName
  这是仅命名的字符串   新窗户。这样的字符串可以用来   成为链接和表单的目标   <a>元素的target属性   或指定<form>。这个   字符串参数不应包含   任何空白。 strWindowName   没有指定新的标题   窗口。

答案 2 :(得分:2)

来自documentation

<强> SNAME

Optional. String that specifies the name of the window. This name is used 
as the value for the TARGET  attribute on a form  or an anchor  element.

_blank
    The sURL is loaded into a new, unnamed window.
_media
    The url is loaded in the Media Bar in Microsoft Internet Explorer 6. 
    Windows XP Service Pack 2 (SP2) and later. This feature is no longer 
    supported. By default the url is loaded into a new browser window or 
    tab.
_parent
    The sURL is loaded into the current frame's parent. If the frame has 
    no parent, this value acts as the value _self.
_search
    Disabled in Windows Internet Explorer 7, see Security and Compatibility 
    in Internet Explorer 7 for details. Otherwise, the sURL is opened in the 
    browser's search pane in Internet Explorer 5 or later.
_self
    The current document is replaced with the specified sURL.
_top
    sURL replaces any framesets that may be loaded. If there are no framesets 
    defined, this value acts as the value _self.