Open a window without focus

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • noon

    Open a window without focus

    Can't get this to work, tried every bit of code I could think of and
    every snippet I could find out there.

    I have a form with the js code in the onsubmit action. I know, I
    shoved it all in there instead of making a function. I don't have
    access to include a .js file or put it in the head, work with me.

    How can I get this to work?

    <form method="get" action="#" onsubmit="var newWin =
    window.open(\'h ttp://google.com/search?q=\'+thi s.imdbSearch.va lue+\'\',
    \'IMDBWindow\') ;window.setTime out(\'self.focu s();\',500);if( !
    newWin.opener) newWin.opener=t his;return false;">
    <input type="text" name="imdbSearc h" size="40">
    <input type="submit" value="Search">
    </form>
  • Stanimir Stamenkov

    #2
    Re: Open a window without focus

    Thu, 14 Feb 2008 09:50:11 -0800 (PST), /noon/:
    How can I get this to work?
    >
    <form method="get" action="#" onsubmit="var newWin =
    window.open(\'h ttp://google.com/search?q=\'+thi s.imdbSearch.va lue+\'\',
    \'IMDBWindow\') ;window.setTime out(\'self.focu s();\',500);if( !
    newWin.opener) newWin.opener=t his;return false;">
    I'm not a JavaScript expert but 'this' in the above statement:

    newWin.opener=t his;

    refers to the <formelement - not to the current window, if that's
    what you want to put there.
    <input type="text" name="imdbSearc h" size="40">
    <input type="submit" value="Search">
    </form>
    --
    Stanimir

    Comment

    • The Natural Philosopher

      #3
      Re: Open a window without focus

      noon wrote:
      Can't get this to work, tried every bit of code I could think of and
      every snippet I could find out there.
      >
      I have a form with the js code in the onsubmit action. I know, I
      shoved it all in there instead of making a function. I don't have
      access to include a .js file or put it in the head, work with me.
      >
      How can I get this to work?
      >
      <form method="get" action="#" onsubmit="var newWin =
      window.open(\'h ttp://google.com/search?q=\'+thi s.imdbSearch.va lue+\'\',
      \'IMDBWindow\') ;window.setTime out(\'self.focu s();\',500);if( !
      newWin.opener) newWin.opener=t his;return false;">
      <input type="text" name="imdbSearc h" size="40">
      <input type="submit" value="Search">
      </form>
      I had the opposite problem. How to move focus relaibly TO the open window..

      i used
      newwin=window.o pen(....)
      newwin.focus();

      IIRC. Try using the above form and newwin.blur()

      Or move focus to the parent.

      Comment

      Working...