本文介绍了来自Java程序员/Web程序员的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要生成一个弹出窗口以显示一些信息.

例如,我有一个名称列表,当我单击它时,我需要那个弹出窗口.
下一个场景是当我单击下一个链接时,第一个弹出窗口应自动关闭,第二个弹出窗口应打开.我该怎么办.

在下面,我发布我的代码.

I need to generate a pop up window to display some information.

As an example i have a name list and when i click on it i need that popup window.
Next scene is when i click on the next link the first pop window should aut o close and second pop up window should open. how can i do that.

Below i post my code.

<script language="javascript" type="text/javascript">
function popitup(url) {
    newwindow=window.open(url,'name','height=200,width=150');
    if (window.focus) {newwindow.focus()}
    return false;
}
</script>
<body>
<a href="a1.html" onclick="return popitup('a1.html')"

    >asdfgh</a>

推荐答案

<script type="text/javascript">

      var currentPopup = null;
      function popitup(url)
      {

          if (currentPopup && currentPopup.open && !currentPopup.closed) {
              currentPopup.close();
          }

          currentPopup = window.open(url, ''name'', ''height=200,width=150'');

          if (window.focus)
          {
              currentPopup.focus()
          }
      return false; }

  </script>





HTML:





Html:

 <a href="#" onclick="return popitup(''test.htm'')">Link1</a>
<a href="#" onclick="return popitup(''test.htm'')">Link2</a>


这篇关于来自Java程序员/Web程序员的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-16 09:08