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 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2002
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Want to change focus to child window.

    I am submitting this form:

    <form method=post name=whform target=blank action=https://ut.secure.bluecrossca.com/wh/landing.do>

    With this link:

    <a href="#" onclick=openWH()>Whole Health Link</a>

    that calls this function:

    function openWH(){
    document.whform.submit();
    }


    What I want to do is if the window that this opens has already been opened by the user, then I just want the link to togle back to the child window. I tried self.blur and that does nothing.

    Any help is greatly appreciated!!!

  • #2
    New Coder
    Join Date
    Aug 2002
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have tried:

    window.blur()
    this.blur()
    self.blur()

    none work. The window that I am working is a child frame, would this matter?

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    Code:
    var win;
    function openWH(){
       var f = document.whform;
       if (!win || win.closed){
           win = window.open('about:blank', f.target);
       }
       win.focus();
       f.submit();
    }
    But if you will make your submit link as input type=submit or type=image, the code will be simpler and will work even if javascript is disabled.
    Code:
    var win;
    function createTargetWin(f){
       f (!win || win.closed){
           win = window.open('about:blank', f.target);
       }
       win.focus();
    }
    <form ... target="blank" onsubmit="createTargetWin(this)">
    ...
    <input type="submit" value="Submit" />
    or
    <input type="image" src="submit.jpg" />
    </form>
    I can't use it in the original code because calling formRef.submit() will unexplicably not trigger the form onsubmit event handler.


  •  

    Posting Permissions

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