how do I close a new window when clicked on it.

Results 1 to 5 of 5

Thread: how do I close a new window when clicked on it.

  1. #1
    supernova Guest

    Default how do I close a new window when clicked on it.

    *<BR>I am new to Javascript.<BR>I have a popup window which is poped up on the OnKeyPress event of a text box. Now..when I click on thic new window it&#039s supposed to close but it does not. WHY??HELP??<BR><BR>my code for mainwindow.asp<BR>&#060;input type="text" name= "text1" OnKeyPress = "javascript:newpopup()"&#062;<BR><BR>&#060;Scr ipt Language="javaScript"&#062;<BR>function calpopup(){<BR> window.open("../newdir/newwindow.asp?","calpopup","toolbar=0,location=0,s tatus=0,menubar=0,scrollbars=0,resizable=1,top=100 ,left=100,width=350,height=200");<BR> }<BR>my code for newwindow.asp<BR><BR>&#060;html&#062;<BR>&#060;BOD Y BGColor="Silver" alink="#526B84" vlink="#526B84" onBlur="javascript:self . focus ()";&#062;<BR><BR>WELCOME!!<BR>&#060;P&#062;*&#06 0;/P&#062;<BR><BR>&#060;/BODY&#062;<BR>&#060;/Html&#062;

  2. #2
    olivia Guest

    Default RE: how do I close a new window when clicked on it

    In the body tag of the pop-up window put:<BR>onBlur="window.close()"

  3. #3
    supernova Guest

    Default RE: how do I close a new window when clicked on it

    that&#039s true.<BR>But this works only for Netscape not for IE.how would I make it work for both the browsers?<BR>Thanks

  4. #4
    olivia Guest

    Default RE: how do I close a new window when clicked on it

    I have used it in both browsers and tested it in 3.0 & 4.0 browsers and have never had any problems.


  5. #5
    MChance Guest

    Default RE: how do I close a new window when clicked on it

    I think what&#039s needed is:<BR><BR>onClick = self.close();<BR><BR>in the body tag of the pop-up. onBlur fires when the window loses keyboard focus, so this would only work if you clicked on the original window. It sounds like you want to have the popup go away when you click on it, not the original window.<BR><BR>Mark Chance

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •