可以用window.name判断!
但是我不是很明白你的问题的意思!
给你举一个例子:
<a href=# target="newwindow">Click</a>
点击它弹出一个新窗口,窗口名为newwindow.
这时,你可以用alert(window.name)得到newwindow这个值!
...说不清楚好象,你到底要问什么?

解决方案 »

  1.   

    不是楼上兄弟的这个意思~我的意思是:
    比仿你打开一个myweb.htm的页子,
    并且你同时也打开其它几个页子
    那么a.htm将会判断:
      如果当前存在窗口名称为newwindow的叶子,则a.htm中有一个值返回1
      如果不存在,则myweb.htm中有一个值返回0请问我如何编写myweb.htm这个页子??
      

  2.   

    这个我就不清楚了,呵呵.因为我不知道如何历遍当前打开的所有窗口!
    假如能够历遍的话,那么判断是否有newwindow很简单了.
    这时,myweb.htm可以这样.
    如果不存在,给自己返回一个值很简单嘛.
    如果存在,要给a.htm返回值,你只需要在myweb.htm里面:
    window.opener=a.htm的窗口名
    然后再用opener传值给a.htm就可以了!关键部分没有搞定,说了等于白说.我们两个一起等待高手赐教!
      

  3.   

    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
    <SCRIPT>
    <!--
    self.resizeTo(300, 300);
    self.moveTo(0, 200);var hasChild = false;var child = null;function openChild()
    {
    if ( hasChild )
    {
    child.document.body.innerHTML += 'hey! I found you!<BR>';
    }
    else
    {
    child = window.open('', 'child', 'width=300, height=200, scrollbars=no');

    child.opener = self; child.document.writeln('<HTML>');
    child.document.writeln('<HEAD>');
    child.document.writeln('<TITLE>child</TITLE>');
    child.document.writeln('<SCRIPT>');
    child.document.writeln('self.moveTo(400, 200);');
    child.document.writeln('');
    child.document.writeln('window.onload =');
    child.document.writeln(' function load()');
    child.document.writeln(' {');
    child.document.writeln(' if ( !opener.closed )');
    child.document.writeln(' {');
    child.document.writeln(' opener.hasChild = true;');
    child.document.writeln(' }');
    child.document.writeln(' }');
    child.document.writeln('');
    child.document.writeln('window.onunload =');
    child.document.writeln(' function unload()');
    child.document.writeln(' {');
    child.document.writeln(' if ( !opener.closed )');
    child.document.writeln(' {');
    child.document.writeln(' opener.hasChild = false;');
    child.document.writeln(' }');
    child.document.writeln(' }');
    child.document.writeln('</SCRIPT>');
    child.document.writeln('</HEAD>');
    child.document.writeln('<BODY>');
    child.document.writeln('</BODY>');
    child.document.writeln('</HTML>');

    child.document.close();
    }
    }
    //-->
    </SCRIPT>
    </HEAD>
    <BODY>
    <INPUT TYPE=button VALUE='Open child Window' ONCLICK='openChild()'>
    </BODY>
    </HTML>
      

  4.   

    不好意思,少了顶部的三行:<HTML>
    <HEAD>
    <TITLE>parent</TITLE>
      

  5.   

    并未覆盖程序流程如下:1. 主窗口
    1.1 根据 hasChild 标志判断是否开启了名字为child的子窗口
    1.2 如果hasChild == true,表示已经开启,则在子窗口中写一行字.
    1.3 如果hasChild == false,表示未开启,则新开一个名字为child的子窗口.并输入需要的数据.2. 子窗口
    2.1 设定onload事件,当子窗口加载时,设定主窗口的hasChild为true,意即告诉主窗口 “俺在,请不要克隆俺.”
    2.2 设定unload事件,当子窗口刷新或者是关闭时,设定主窗口的hasChild为false,意即告诉主窗口 “俺即将重生或者翘翘,有空可以重新call我出来”.另:在子窗口中的 if ( !opener.cosed ) 表示检测主窗口是否已经关闭.如果主窗口已经关闭,子窗口就没有必要向主窗口汇报当前动向.
      

  6.   

    再次感谢 cm4ever(一肚子坏水) 的支持!~```稍后40分归你!当仍然不是你的意思~ 你的算法是通过child窗口来设定一个判断值的如果child是其他网站的页子 我还能做到这一点吗?~~~~(比如在别人的页子中用<a hrf="a.htm" target="child">来打开一个窗口~ 现在用我的页子能判断出child存在与否吗?) 急!!!!!!!!!!!!!!
      

  7.   

    不好意思.这牛皮吹得有点大了.花了几乎整个下午的时间.经过我仔细研究再研究,发现原来的设计思想简直就是画蛇添足,其实不用加bool变量也可以判断子窗口.代码如下:一、父窗口parent.htm代码:<!----------parent.htm begin---------->
    <HTML>
    <HEAD>
    <TITLE>parent</TITLE>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
    <SCRIPT>
    <!--
    self.resizeTo(300, 300);
    self.moveTo(0, 200);var child = null;function openChild()
    {
    if ( child == null || (child != null && child.closed) )
    {
    document.body.innerHTML += child == null ? 'child == null<BR>' : 'child != null && child.closed<BR>';

    child = window.open('child.htm', 'child', 'width=300, height=200, scrollbars=yes');

    child.opener = self;
    }
    else
    if ( !child.closed )
    {
    document.body.innerHTML += '!child.closed<BR>';

    child.document.body.innerHTML +=  'hey! I found you!<BR>';
    }

    }
    //-->
    </SCRIPT>
    </HEAD>
    <BODY>
    <INPUT TYPE=button VALUE='Open child Window' ONCLICK='openChild()'>
    <BR>
    </BODY>
    </HTML>
    <!----------parent.htm end---------->二、子窗口child.htm代码:<!----------child.htm begin---------->
    <HTML>
    <HEAD>
    <TITLE>child</TITLE>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
    </HEAD>
    <BODY>
    <BR>I'm child window<BR>
    </BODY>
    </HTML>
    <!----------child.htm end---------->
      

  8.   

    三、如果你想在子窗口中加入一些script做些事情.可以这样做:1. 在parent.htm的child.opener = self; 这一句后面加入:while ( child.document.readyState != 'complete' );

    var head = null;

    var html = child.document.body.parentNode;

    for ( i = 0; i < html.children.length; i++ )
    {
    if ( html.children(i).tagName == 'HEAD' )
    {
    head = html.children(i);

    break;
    }
    }

    if ( head != null )
    {
    var script = child.document.createElement('SCRIPT');

    script.src = 'control.js';

    script.charset = 'UTF-8';

    head.appendChild(script);
    }2. 接着将javascript代码写在control.js文件中.就可以了.比如:
    // control.js begin// 移动子窗口
    self.moveTo(400, 200);// control.js end四、本程序是随手写的,没有经过严密的思考,再加上本人水平很弱,所以各位如果有更好的方法或改进其中的不足之处,并拿出来共享,本人不胜感激.
      

  9.   

    晕!~~~  我想还是结帐吧!`````可能由于我描述的不够清楚~``你又误解了我的意思~`:(也许这个问题就根本无法解决!:)cm4ever(一肚子坏水) 如果你不厌烦此问题或对该感兴趣 希望能加我的QQ` 让我细细描述`我的QQ:41708148 
      

  10.   

    <!----------parent.htm begin---------->
    <HTML>
    <HEAD>
    <TITLE>parent</TITLE>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
    <SCRIPT>
    <!--
    function child(win, url, name, features)
    {
    this.win      = win;

    this.url      = url;
    this.name     = name;
    this.features = features;
    }function CheckWindow()
    {
    this.children = new Array();

    this.count = 0;

    this.insert =
    function(child)
    {
    this.children[this.count++] = child;
    }

    this.update =
    function(i, child)
    {
    this.children[i] = child;
    }

    this.search = 
    function(name)
    {
    for ( i = 0; i < this.count; i++ )
    {
    if ( this.children[i].name == name )
    {
    return i;
    }
    } return -1;
    }

    this.check =
    function(i)
    {
    if ( this.children[i].win != null && !this.children[i].win.closed )
    {
    return true;
    }

    return false;
    }

    this.open = 
    function(url, name, features)
    {
    var i = -1;

    if ( (i = this.search(name)) == -1 )
    {
    win = window.open(url, name, features);

    win.opener = self;

    this.insert(new child(win, url, name, features));
    }
    else
    {
    if ( this.check(i) )
    {
    alert('名称为 "' + this.children[i].name + '" 的窗口已开启');
    }
    else
    {
    win = window.open(url, name, features);

    win.opener = self;

    this.update(i, new child(win, url, name, features));
    }
    }
    }
    }var cw = new CheckWindow();
    //-->
    </SCRIPT>
    </HEAD>
    <BODY>
    url: <INPUT TYPE=text Name='url' VALUE='http://cn.yahoo.com'><BR>
    name: <INPUT TYPE=text NAME='windowName'><BR>
    features: <INPUT Type=text NAME='features'><BR>
    <INPUT TYPE=button VALUE='open' onClick='cw.open(url.value, windowName.value, features.value)'>
    <A HREF="javascript:cw.open(url.value, windowName.value, features.value)">open</A>
    <BR>
    </BODY>
    </HTML>
    <!----------parent.htm end---------->
      

  11.   

    我用下面的网页打开一个名字叫winName的网页:
    <body>
    <a href="http://www.163.com" target="winName">163电子信箱</a>
    </body>现在我需要制作一个符合下面条件的网页:
    1.名字为winName的网页不被覆盖
    2.能证明当前已经存在一个名字为"winName"的网页