Open a window without focus

Discussion in 'Javascript' started by noon, Feb 14, 2008.

  1. noon

    noon Guest

    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(\'http://google.com/search?q=\'+this.imdbSearch.value+\'\',
    \'IMDBWindow\');window.setTimeout(\'self.focus();\',500);if(!
    newWin.opener) newWin.opener=this;return false;">
    <input type="text" name="imdbSearch" size="40">
    <input type="submit" value="Search">
    </form>
     
    noon, Feb 14, 2008
    #1
    1. Advertising

  2. 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(\'http://google.com/search?q=\'+this.imdbSearch.value+\'\',
    > \'IMDBWindow\');window.setTimeout(\'self.focus();\',500);if(!
    > newWin.opener) newWin.opener=this;return false;">


    I'm not a JavaScript expert but 'this' in the above statement:

    newWin.opener=this;

    refers to the <form> element - not to the current window, if that's
    what you want to put there.

    > <input type="text" name="imdbSearch" size="40">
    > <input type="submit" value="Search">
    > </form>


    --
    Stanimir
     
    Stanimir Stamenkov, Feb 14, 2008
    #2
    1. Advertising

  3. 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(\'http://google.com/search?q=\'+this.imdbSearch.value+\'\',
    > \'IMDBWindow\');window.setTimeout(\'self.focus();\',500);if(!
    > newWin.opener) newWin.opener=this;return false;">
    > <input type="text" name="imdbSearch" 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.open(....)
    newwin.focus();

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

    Or move focus to the parent.
     
    The Natural Philosopher, Feb 14, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan
    Replies:
    8
    Views:
    8,368
  2. Jason
    Replies:
    4
    Views:
    1,683
    Jason
    May 7, 2007
  3. Csaba Gabor

    focus on the new window.open window

    Csaba Gabor, Nov 30, 2005, in forum: Javascript
    Replies:
    4
    Views:
    228
    Csaba Gabor
    Dec 1, 2005
  4. Roger
    Replies:
    3
    Views:
    379
  5. Spizzat2
    Replies:
    2
    Views:
    195
    Spizzat2
    Jan 9, 2008
Loading...

Share This Page