45 users online (1 members and 44 guests)  


  Results 1 to 11 of 11

Related

  1. How do I get onUnload to close a window    Forum: Javascript Forum
    Replies: 0
  2. close window    Forum: Javascript Forum
    Replies: 0
  3. close window    Forum: Javascript Forum
    Replies: 3
  4. onblur=window.close() trubles    Forum: Javascript Forum
    Replies: 0
  5. onFocus to close a window    Forum: Javascript Forum
    Replies: 1
  1. #1
    SCG's Avatar
    New User

    Status
    Offline
    Join Date
    Aug 2003
    Posts
    10

    ONBLUR to close a window

    Hi,
    I'm using
    Code:
    ONBLUR="window.close();"
    to close a popup window when the user clicks back to the parent window. The popup windows plays a sample piece of music.
    In Netscape this works OK - the user can click the media player in the window to stop and restart the music. But in IE any clicking inside the popup windows closes it.
    Is there something I'm doing wrong or is it just IE being crappy?
    Thanks
    Last edited by HTML; 09-30-2003 at 06:37 PM.

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hello,

    It depends where the onBlur is placed. If you could provide your code, we can probably make a better guess than that.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    Derek's Avatar
    Be Yourself

    Status
    Offline
    Join Date
    Aug 2001
    Location
    St. George, Utah, USA
    Posts
    466
    It's kind of amazing how many times that has to be said every week... lol.

  4. #4
    SCG's Avatar
    New User

    Status
    Offline
    Join Date
    Aug 2003
    Posts
    10
    Quote Originally Posted by QuietDean
    Hello,

    It depends where the onBlur is placed. If you could provide your code, we can probably make a better guess than that.
    Hi - sorry - I'm new to this (both to this forum, and to CSS/javascript/DHTML).

    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0//EN" "hmpro6.dtd">
    <HTML> 
      <HEAD> 
    	 <TITLE></TITLE> 
      </HEAD> 
      <BODY BGCOLOR="#FFFFCC" ONBLUR="window.close();"> 
    	 <TABLE> 
    		<TR VALIGN="TOP"> 
    		  <TD VALIGN="TOP" ALIGN="CENTER" COLSPAN="2">
    			 <OBJECT WIDTH="300" HEIGHT="45"> <PARAM NAME="hidden" VALUE="false">
    			 <PARAM NAME="loop" VALUE="false"> <PARAM NAME="autostart" VALUE="true">
    			 <PARAM NAME="src" VALUE="wav/hope.wav">
    			 <EMBED SRC="wav/hope.wav" WIDTH="300" HEIGHT="45" AUTOSTART="true" LOOP="false"
    			  HIDDEN="false"> </OBJECT> <BR><B><FONT SIZE="+1">Hope Is The
    			 Anchor</FONT></B><BR> 
    			 <FORM>
    				<INPUT TYPE="button" VALUE="Click to Close" ONCLICK="self.close()">
    				</FORM></TD> 
    		</TR> 
    	 </TABLE> </BODY>
    </HTML>
    Last edited by HTML; 09-30-2003 at 06:33 PM.

  5. #5
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Ah. That makes sense.

    BODY loses focus when focus is placed on elements within the BODY. So its actually NetScape thats incorrect in this instance, I guess.

    A workaround is to move the processing from the child to the parent window. here is a very simple snippet I used to test if this would work -

    Code:
    <body onfocus="if (window.win) {window.win.close()}">
    <a href="#" onclick="win=window.open('tester.html', 'badger')">badger</a>
    </body>
    So basically, on the focus of the parent window, it checks whether thr child popup exists, and kills it if it does. Hope that helps.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  6. #6
    SCG's Avatar
    New User

    Status
    Offline
    Join Date
    Aug 2003
    Posts
    10
    Thanks,
    I'll give it a try

  7. #7
    SCG's Avatar
    New User

    Status
    Offline
    Join Date
    Aug 2003
    Posts
    10

    Wink

    That worked fine. many thanks for that.

    I have a couple of supplementary questions:

    1. I don't have anything equivalent to the "badger" elements in your example. Am I missing something I should have. Code I have is:

    HTML Code:
    <TD><A HREF="#" ONCLICK="win=window.open('ND_CD_rose.htm',null,'scrollbars=yes,left=0,top=100,width=750,height=400')">
    <IMG SRC="Gifs/Other/CD_rose.gif" ALIGN="MIDDLE" WIDTH="140" HEIGHT="15" BORDER="0"></A></TD>
    (I have just shown one table element as an example)

    2. Secondly the table is part way down a page. When the user clicks the selection and the child window opens the parent window goes back to the top, so that when the child is closed they have to scroll down the parent window to get back to the selection. Is there any way of fixing the position where they left the parent so that they return there?
    Last edited by HTML; 09-30-2003 at 06:40 PM.

  8. #8
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hello.

    1) Dont worry about Badger, thats just the window name, I always use badger

    2) Ah. thats my fault. Its jumping up the page because of href="#"

    use href="javascript:void(0);" instead.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  9. #9
    SCG's Avatar
    New User

    Status
    Offline
    Join Date
    Aug 2003
    Posts
    10

    Cool

    That works fine - thanks.

    Ref the "#" - I was already using this to create child windows quite extensively and it was very irritating when the parent kept returning to the top.

    Got the code from a book (as I did the ONBLUR). Just goes to show that books are OK to get started but a forum like this is invaluable to tap into expertise.

  10. #10
    bibi's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2004
    Posts
    4

    onblur=window.close() trubles

    hi!
    my code works on NN but not on IE6.
    I want the child window close when i click on the parent window.

    here is the code...
    please help me...

    java script
    =====
    function win() {

    var content="<center>"+"{/literal}{$popup}{literal}"+"</center>";
    var temp="{/literal}{$popup}{literal}";

    if (!temp==""){

    msg=window.open("","msg","height=200,width=300,left=920,top=500,toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0",'');
    msg.document.write("<html><TITLE>INFO</TITLE>");
    msg.document.write("<body bgcolor='#FFFFCC' onBlur='window.close()' >");


    msg.document.write(content);
    msg.document.write("</body></html>");
    }

    else
    {
    alert ("Choose a menu!");
    }



    }


    html section
    ---------

    <form name="hide_form" >
    <img src="help_btn.gif" onClick="JavaScript:win()" height="40" width="40">

    </form>

    all these are in the samefile... all variables are ok...the problem is that thechild win doesn't close

    thank you

  11. #11
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hi,

    Please start a new thread for new problems.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?



Tags for this Thread