Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    New Coder
    Join Date
    Sep 2005
    Location
    Latina (Italy)
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to recognize a child window

    I'm desperatedly trying to find a way to make something like this:
    a parent window creates a new window;
    when pressing an anchor, the child window blurs;
    the the parent window understand this and reload itself to the URI the child window would like to make it load.

    I'd like to understand how to make this but I don't find a way to afford this task. Can someone help me please?

  • #2
    New Coder
    Join Date
    Sep 2005
    Location
    Latina (Italy)
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    window.blur()

    It was easier than how I expected!
    This works perfectly on Internet Explorer: just activate this from anchors as onclick function:
    Code:
    function parentReload( newHref )
    {	var parentWindow=window.opener;
    	parentWindow.location.assign(newHref);
    	window.blur();
    	parentWindow.focus();
    }
    I publish my (incomplete) solution anyway because another problem came out: why
    Code:
    window.blur()
    doesn't work on Mozilla Firefox? Is there another solution?

  • #3
    New Coder
    Join Date
    Oct 2005
    Posts
    87
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I'm using firefox version 1.5b2 and the blur command works fine. What version are you using?

    Just a thought, but try removing the semicolons from the end of blur() and focus().
    Last edited by pccode; 10-16-2005 at 10:33 AM.

  • #4
    New Coder
    Join Date
    Sep 2005
    Location
    Latina (Italy)
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts
    My version is 1.0.7 and it doesn't work (neither on NN), even if removing the semicolons...

  • #5
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Quote Originally Posted by pccode
    I'm using firefox version 1.5b2 and the blur command works fine. What version are you using?

    Just a thought, but try removing the semicolons from the end of blur() and focus().
    !!!! Leave them in! It's much much better to create properly formed javascript, delimiting ends of line with semi-colons.

    what about this as a cross-browser solution?
    Code:
    function parentReload(newHref){
    	if(parent && !parent.closed) {
    		parent.location.href = newHref;
    		window.blur();
    		parent.focus();
    	}
    }
    m_n
    "Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
    and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
    -Tommy Cooper

  • #6
    New Coder
    Join Date
    Sep 2005
    Location
    Latina (Italy)
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's the problem: the window.blur() method.
    It doesn't work on Mozilla... and I don't really understand why!

  • #7
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    window.blur() is a fully supported method of the window object in the Gecko DOM:
    http://developer.mozilla.org/en/docs/DOM:window.blur

    Potentially it could be that your current initial ordering of windows is slighty skewed? Also, Firefox has options to disable scripts from focusing and blurring windows - you might want to check these option settings on your computer.

    m_n
    Last edited by martin_narg; 10-17-2005 at 01:39 AM.
    "Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
    and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
    -Tommy Cooper

  • #8
    New Coder
    Join Date
    Sep 2005
    Location
    Latina (Italy)
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The 'move or resize existing windows' and 'raise or lower windows' options are both checked but it doesn't work anyway...
    Strange, isn't it??

    Could you suggest me another way to hide the child window, which is not the blur()-call?

    Thanx a lot!!

  • #9
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    The blur should work but it doesn't get executed because the location object does not have assign method. Check the Javascript Console to see this possible error. But you don't need to blur it because if you set focus to the opener window, the current window will lose focus.
    Code:
    function parentReload( newHref )
    {	
        var parentWindow=window.opener;
        if (parentWindow && !parentWindow.closed){ //check if opener is still open
    	parentWindow.location.href = newHref;
    	parentWindow.focus();
        }
    }
    Last edited by glenngv; 10-17-2005 at 09:55 AM.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #10
    New Coder
    Join Date
    Sep 2005
    Location
    Latina (Italy)
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts
    THanx for having remembered me to check if the opener was closed!!
    The problem is that the page changes in the opener, but the focus doesn't shift from the child to the parent window...

  • #11
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Is the popup page in the same domain as the opener? Check the Javascript Console for any error.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #12
    New Coder
    Join Date
    Sep 2005
    Location
    Latina (Italy)
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No error in the js console.
    Maybe the problem is the direct call into an anchor?

    I mean, that function is directly called so:
    Code:
    <a href="javascript:parentReload(..)" ... >
    is this the reason perhaps?

    Naaa I don't think so

  • #13
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    It might be the "Raise or lower windows" setting in the Advanced Javascript Options is unchecked. This is what martin_narg said in his post.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #14
    New Coder
    Join Date
    Sep 2005
    Location
    Latina (Italy)
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by cdc08x
    The 'move or resize existing windows' and 'raise or lower windows' are both checked
    Gosh....
    Thanx a lot for your help I hope I'm not annoying you

  • #15
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Do you have the page online? If not, would it be possible for you to create a sample page that shows the behavior?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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