JS opening two windows instead of one

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

    JS opening two windows instead of one

    When this form's being submitted, two windows are opening instead of only
    one
    here is the function I'm using:

    function subForm(){
    //insert form validation here
    //if form is valid, open a pop-window & submit
    subWin =
    window.open("ht tp://www.smoochya.co m/books.html","su bWin","width=55 0,height=
    350,address=no" )
    document.SendSc ore.action = "tellafriend_qu iz1.php"
    document.SendSc ore.method = "post"
    document.SendSc ore.target = subWin
    document.SendSc ore.submit()
    }

    here is the form in the HTML body:
    <FORM NAME="SendScore " >
    <INPUT TYPE="hidden" name="numbercor rect" value="">
    <INPUT TYPE="IMAGE" onClick="subFor m()" SRC="/images/passitalong_qui z.jpg"[color=blue]
    >[/color]
    </FORM>

    the only other thing going on which probably is not interfering is the fact
    that I'm making that "hidden" variable switch to a javascript variable from
    being submitted by another form page that comes before this one.
    I'm calling it in the BODY tag using onLoad="Javascr ipt:
    SwitchNumberRig ht();" which calls this function:

    function SwitchNumberRig ht(){
    document.SendSc ore.numbercorre ct.value = numberright;
    }

    anyway the code can be viewed by going to http://www.smoochya.com/quiz1.html
    and picking some answers (or not picking any) on the quiz. You'll notice
    that one of the windows gives you your score while the other one (without
    any toolbars) doesn't. Can't seem to get it to open only one window with the
    score included.

    Any help greatly appreciated..
    Thanks,
    M


  • Lee

    #2
    Re: JS opening two windows instead of one

    Display Name said:[color=blue]
    >
    >When this form's being submitted, two windows are opening instead of only
    >one
    >here is the function I'm using:
    >
    >function subForm(){
    > //insert form validation here
    > //if form is valid, open a pop-window & submit
    > subWin =
    >window.open("h ttp://www.smoochya.co m/books.html","su bWin","width=55 0,height=
    >350,address=no ")
    > document.SendSc ore.action = "tellafriend_qu iz1.php"
    > document.SendSc ore.method = "post"
    > document.SendSc ore.target = subWin
    > document.SendSc ore.submit()
    >}[/color]

    You're getting a second window because the window you open()
    is not being set as the target of the form.

    document.SendSc ore.target = "subWin"

    The value of the target attribute is the name of the window, not
    a reference to the window.

    Comment

    • @SM

      #3
      Re: JS opening two windows instead of one



      Lee a *crit :
      [color=blue]
      > Display Name said:[color=green]
      > >
      > >When this form's being submitted, two windows are opening instead of only
      > >one
      > >here is the function I'm using:
      > >
      > >function subForm(){
      > > //insert form validation here
      > > //if form is valid, open a pop-window & submit[/color][/color]

      change the name of your popup
      [color=blue]
      >[color=green]
      > > subWin =[/color][/color]

      popWin=
      [color=blue][color=green]
      > >window.open("h ttp://www.smoochya.co m/books.html","su bWin","width=55 0,height=
      > >350,address=no ")
      > > document.SendSc ore.action = "tellafriend_qu iz1.php"
      > > document.SendSc ore.method = "post"[/color][/color]

      document.SendSc ore.method = "get"
      [color=blue][color=green]
      > > document.SendSc ore.target = subWin[/color][/color]

      document.SendSc ore.target = "subWin"
      [color=blue][color=green]
      > > document.SendSc ore.submit()
      > >}[/color]
      >
      > You're getting a second window because the window you open()
      > is not being set as the target of the form.[/color]

      and this window has same name as target ...
      [color=blue]
      > document.SendSc ore.target = "subWin"
      >
      > The value of the target attribute is the name of the window, not
      > a reference to the window.[/color]

      I think (but I could bad understand you) that the 'target'
      is the target included in the window
      truc = window.open('ur l','target','at tributes');
      or with :
      truc=window.ope n('page.htm','c hose','width=30 0,height=300,re sizable=0');

      onclick="truc.l ocation = 'page_2.htm';"
      would work as
      <a href="page_2.ht m" target="chose"> page 2</a>


      --
      *************** *************** *************** *************** **
      Stéphane MORIAUX : mailto:stephane OTER-MOImoriaux@wana doo.fr
      Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)

      *************** *************** *************** *************** **


      Comment

      • Display Name

        #4
        Re: JS opening two windows instead of one

        Stephane...
        you're the man. your edits worked even w/o having to adjust the target
        parameters. thanks a lot!
        M

        "@SM" <stephane_moria ux@wanadoo.fr> wrote in message
        news:3FD7C628.F AF96F40@wanadoo .fr...[color=blue]
        >
        >
        > Lee a *crit :
        >[color=green]
        > > Display Name said:[color=darkred]
        > > >
        > > >When this form's being submitted, two windows are opening instead of[/color][/color][/color]
        only[color=blue][color=green][color=darkred]
        > > >one
        > > >here is the function I'm using:
        > > >
        > > >function subForm(){
        > > > //insert form validation here
        > > > //if form is valid, open a pop-window & submit[/color][/color]
        >
        > change the name of your popup
        >[color=green]
        > >[color=darkred]
        > > > subWin =[/color][/color]
        >
        > popWin=
        >[color=green]
        > >[/color]
        >window.open("h ttp://www.smoochya.co m/books.html","su bWin","width=55 0,height[/color]
        =[color=blue][color=green][color=darkred]
        > > >350,address=no ")
        > > > document.SendSc ore.action = "tellafriend_qu iz1.php"
        > > > document.SendSc ore.method = "post"[/color][/color]
        >
        > document.SendSc ore.method = "get"
        >[color=green][color=darkred]
        > > > document.SendSc ore.target = subWin[/color][/color]
        >
        > document.SendSc ore.target = "subWin"
        >[color=green][color=darkred]
        > > > document.SendSc ore.submit()
        > > >}[/color]
        > >
        > > You're getting a second window because the window you open()
        > > is not being set as the target of the form.[/color]
        >
        > and this window has same name as target ...
        >[color=green]
        > > document.SendSc ore.target = "subWin"
        > >
        > > The value of the target attribute is the name of the window, not
        > > a reference to the window.[/color]
        >
        > I think (but I could bad understand you) that the 'target'
        > is the target included in the window
        > truc = window.open('ur l','target','at tributes');
        > or with :
        > truc=window.ope n('page.htm','c hose','width=30 0,height=300,re sizable=0');
        >
        > onclick="truc.l ocation = 'page_2.htm';"
        > would work as
        > <a href="page_2.ht m" target="chose"> page 2</a>
        >
        >
        > --
        > *************** *************** *************** *************** **
        > Stéphane MORIAUX : mailto:stephane OTER-MOImoriaux@wana doo.fr
        > Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
        > http://perso.wanadoo.fr/stephanemoriaux/internet/
        > *************** *************** *************** *************** **
        >
        >[/color]


        Comment

        Working...