如何在打开弹出窗口时禁用父窗口?

时间:2016-03-21 07:52:02

标签: javascript html

如何禁用父窗口,只关注具有以下代码的弹出窗口?

<body onFocus="parent_disable();" onclick="parent_disable();">
<div class="login-box">
  <form action="post" class="login-form">
    <div class="form-group">
      <label for="user-name">Username:</label>
      <input id="user-name" type="text" name="user" required>
    </div>
    <div class="form-group">
      <label for="password">Password:</label>
      <input id="password" type="password" name="password">
    </div>
    <div class="button-container text-right">
      <button class="btn btn-default" type="button" id="btn-cancel">Cancel</button>
      <button class="btn btn-primary" type="button" id="btn-login">Login</button>
    </div>
  </form>
  <a href="ForgotPassword.html" onclick="return popup(this, 'Signup')">Forgot password</a>
  <p>Don't have an account? <a href="javascript:child_open()" >Sign up</a> here</p>
</div>

<script type="text/javascript">
    var popupWindow=null;
    function child_open(){ 
        popupWindow =window.open('Signup.jsp',"_blank","directories=no, status=no, menubar=no, scrollbars=yes, resizable=no,width=600, height=280,top=200,left=200");
    }
    function parent_disable() {
        if(popupWindow && !popupWindow.closed)
        popupWindow.focus();
    }
</script>
</body>

我已尝试过stackover流程中的一些建议,但它们对我都没有用。请有人帮忙解决这个问题。

0 个答案:

没有答案