function OpenHideWin(theURL)
{
      hPopup = window.open(theURL, "HideWin", "width=1,height=1,copyhistory=1,location=1,status=1,toolbar=1,directories=1,menubar=1,scrollbars=1,resizable=1,top=0,left=0");
      window.focus();
      hPopup.resizeTo(screen.availWidth, screen.availHeight);
}

解决方案 »

  1.   

    你的函数没有问题啊,我试过了,下面是代码,但是如果你在点击第一个链接之后把这个窗口关掉了,那么之后你在点击第二个链接也没有用的。
    <html>
    <head>
    <script>
    var hPopup=""
    function OpenHideWin(theURL)
    {
       
       if (hPopup=="")
       {
          alert("hpopup=")
          hPopup=window.open("", "HideWin", "width=1,height=1,copyhistory=1,location=1,status=1,toolbar=1,directories=1,menubar=1,scrollbars=1,resizable=1,top=0,left=0");
          window.focus();
          hPopup.resizeTo(screen.availWidth, screen.availHeight);
       }
       hPopup.location = theURL;
    }
    </script>
    </head>
    <body>
    <a href="javascript:OpenHideWin('001.htm')">the first</a>
    <br>
    <a href="javascript:OpenHideWin('002.htm')">the second</a>
    </body>
    </html>
      

  2.   

    是没问题
    但是我的调用是OpenHideWin('http:\/\/www.xxx.com\/xxx\/xxx')
    有时候可以的
    今天我看别人的代码,应该是这样的OpenHideWin('http://www.xxx.com/xxx/xxx')
    到底要不要\?
    我发现要了(有时)行,不要也行呀?
      

  3.   

    不要\的
    反斜杠是在老的浏览器版本用的
    那时要写成这样
    document.write("<\/br>")
    现在在字符串里面很多情况下不用\了
    至少在你的这种情况不用
      

  4.   

    本来我是不用的,后来我在用indexOf这个函数时,发现包含'\'的字符串如果不预先写成'\\'就会找不到。
    例如,
    var str="C:\\WINNT";
    var tmp=str.indexOf("\\");
    如果任一个"\\"写成'\'都会得不到预想的结果
      

  5.   

    楼主的hPopup.location = theURL;应该是hPopup.location.href = theURL;
    按的需要,不用这么复杂,可以直接实现
    打开第一个
    window.open("第一个连接","HideWin", "width=1,height=1,copyhistory=1,location=1,status=1,toolbar=1,directories=1,menubar=1,scrollbars=1,resizable=1,top=0,left=0");
    打开第二个
    window.open("第二个连接","HideWin", "width=1,height=1,copyhistory=1,location=1,status=1,toolbar=1,directories=1,menubar=1,scrollbars=1,resizable=1,top=0,left=0");
    对其做操作时可以用  HideWin.location.href='';
      

  6.   

    错了!!!重发
    楼主的hPopup.location = theURL;应该是hPopup.location.href = theURL;
    按的需要,不用这么复杂,可以直接实现
    打开第一个
    window.open("第一个连接","HideWin", "width=1,height=1,copyhistory=1,location=1,status=1,toolbar=1,directories=1,menubar=1,scrollbars=1,resizable=1,top=0,left=0");
    打开第二个
    window.open("第二个连接","HideWin", "width=1,height=1,copyhistory=1,location=1,status=1,toolbar=1,directories=1,menubar=1,scrollbars=1,resizable=1,top=0,left=0");
    只要窗口名相同再次OPEN时就可以直接替换!
      

  7.   

    window.open的第二个参数是句柄,相同的话就只能打开一个
      

  8.   

    我也需要解决这个问题。看了一下 fason(【阿信(你是我的温柔)】) 的发言。搞定了
    在这里谢谢了
      

  9.   

    我发现原因了!我把函数重新写成
    function OpenHideWin(theURL)
    {
       var hPopup = window.open("", "HideWin", "width=1,height=1,copyhistory=1,location=1,status=1,toolbar=1,directories=1,menubar=1,scrollbars=1,resizable=1,top=0,left=0");
       hPopup.blur();
       hPopup.resizeTo(screen.availWidth, screen.availHeight);
       hPopup.location = theURL;
    }
    我发现只要第一次的连接的加载过程完成,再调用这个函数就可以直接替换原来的内容。但是如果第一次的加载(比如还有一个图片没有下载完)还没有完成,第二次调用这个函数就没有任何效果。请问高手如何在用javascript中止第一次加载并使得第二次的调用有效???
      

  10.   

    为什么要通过设置hpopup.location呢?
    window.open的第一个参数设置url就可以阿,因为window.open第二个参数是不变的,只会打开一个窗口。如下:function OpenHideWin(theURL)
    {
       var hPopup = window.open(theURL, "HideWin", "width=1,height=1,copyhistory=1,location=1,status=1,toolbar=1,directories=1,menubar=1,scrollbars=1,resizable=1,top=0,left=0");
       hPopup.blur();
       hPopup.resizeTo(screen.availWidth, screen.availHeight);
       
    }
      

  11.   

    stanely,行吗?
    我记得我试过的,结果“hPopup.resizeTo(screen.availWidth, screen.availHeight);”这个句子就没效果了,据说是javascript无法控制一个已经打开了输入流的窗口,我只好先置空,再用“hpopup.location=theURL;”来连接。你再试试看你那样做“hPopup.resizeTo(screen.availWidth, screen.availHeight);”这个句子有没有效果?