Window.open. Works in ie6. Does not work in firefox

Discussion in 'Javascript' started by dlf, Jun 9, 2008.

  1. dlf

    dlf Guest

    Hello,

    I'm building a little web with php and javascript. I have inside HEAD
    the following function:

    This function receives as parameters a url and a string. In the url it
    changes "aaaa" chars, inserting the value received in the string.

    <script type="text/javascript">
    function abrir(url,cadena){
    nuevaurl=url.replace("aaaa",cadena);
    window.open(nuevaurl);
    }
    </script>

    I call it with these lines:
    <INPUT onclick='abrir("<? echo$row_lista['url'];?>",unico.value)'
    type=button value=OK name=button_nameprod>

    My problem is that it works perfectly with ie6, but not with firefox.
    I push the button and it happens nothing.

    Any suggestion? Is it something related to my use of window.open?
    Thanks a lot!
     
    dlf, Jun 9, 2008
    #1
    1. Advertising

  2. dlf wrote:
    > Hello,
    >
    > I'm building a little web with php and javascript. I have inside HEAD
    > the following function:
    >
    > This function receives as parameters a url and a string. In the url it
    > changes "aaaa" chars, inserting the value received in the string.
    >
    > <script type="text/javascript">
    > function abrir(url,cadena){
    > nuevaurl=url.replace("aaaa",cadena);
    > window.open(nuevaurl);
    > }
    > </script>


    Works fine here.

    >
    > I call it with these lines:
    > <INPUT onclick='abrir("<? echo$row_lista['url'];?>",unico.value)'
    > type=button value=OK name=button_nameprod>


    Is 'unico.value' set?

    >
    > My problem is that it works perfectly with ie6, but not with firefox.
    > I push the button and it happens nothing.


    What version are you using? Install 'firebug': it's a perfect tool for
    debugging things like this:

    http://www.getfirebug.com/

    Bart
     
    Bart Friederichs, Jun 9, 2008
    #2
    1. Advertising

  3. dlf

    Evertjan. Guest

    dlf wrote on 09 jun 2008 in comp.lang.javascript:

    >
    > Hello,
    >
    > I'm building a little web with php and javascript. I have inside HEAD
    > the following function:
    >
    > This function receives as parameters a url and a string. In the url it
    > changes "aaaa" chars, inserting the value received in the string.
    >
    > <script type="text/javascript">
    > function abrir(url,cadena){
    > nuevaurl=url.replace("aaaa",cadena);


    replace() needs a regular expression, not a string.

    You should mention the error text and the error line number,
    and do some debugging.

    > window.open(nuevaurl);
    >}
    > </script>
    >
    > I call it with these lines:
    > <INPUT onclick='abrir("<? echo$row_lista['url'];?>",unico.value)'
    > type=button value=OK name=button_nameprod>
    >
    > My problem is that it works perfectly with ie6, but not with firefox.
    > I push the button and it happens nothing.
    >
    > Any suggestion? Is it something related to my use of window.open?
    > Thanks a lot!
    >




    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Jun 9, 2008
    #3
  4. Try:

    > function abrir(url,cadena){
    > nuevaurl=url.replace("aaaa",cadena);


    var nuevaurl = url.replace(/aaaa/, cadena);

    > window.open(nuevaurl);


    The "var" keyword makes the variable local to the funcion.
    Also, replace()'s first argument must be a regular expression.


    --
    -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
    -- Mi sitio sobre programación web: http://bits.demogracia.com
    -- Mi web de humor al baño María: http://www.demogracia.com
    --
     
    Álvaro G. Vicario, Jun 9, 2008
    #4
  5. dlf

    dlf Guest

    On 9 jun, 17:46, "Evertjan." <> wrote:
    > dlf wrote on 09 jun 2008 in comp.lang.javascript:
    >
    >
    >
    > > Hello,

    >
    > > I'm building a little web with php and javascript. I have inside HEAD
    > > the following function:

    >
    > > This function receives as parameters a url and a string. In the url it
    > > changes "aaaa" chars, inserting the value received in the string.

    >
    > > <script type="text/javascript">
    > > function abrir(url,cadena){
    > > nuevaurl=url.replace("aaaa",cadena);

    >
    > replace() needs a regular expression, not a string.
    >
    > You should mention the error text and the error line number,
    > and do some debugging.
    >
    > > window.open(nuevaurl);
    > >}
    > > </script>

    >
    > > I call it with these lines:
    > > <INPUT onclick='abrir("<? echo$row_lista['url'];?>",unico.value)'
    > > type=button value=OK name=button_nameprod>

    >
    > > My problem is that it works perfectly with ie6, but not with firefox.
    > > I push the button and it happens nothing.

    >
    > > Any suggestion? Is it something related to my use of window.open?
    > > Thanks a lot!

    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)


    Hi,

    Thanks a lot for your responses. I will check firebug.

    unico.value is set, yes.

    In fact i don't receive any error. The window simply does not appear :-
    (

    Regards,
    David
     
    dlf, Jun 9, 2008
    #5
  6. dlf

    Evertjan. Guest

    dlf wrote on 09 jun 2008 in comp.lang.javascript:

    >> > <script type="text/javascript">
    >> > function abrir(url,cadena){
    >> > nuevaurl=url.replace("aaaa",cadena);

    >>
    >> replace() needs a regular expression, not a string.
    >>
    >> You should mention the error text and the error line number,
    >> and do some debugging.
    >>
    >> > window.open(nuevaurl);
    >> >}
    >> > </script>

    >>


    [please do not quote signatures on usenet]

    > Thanks a lot for your responses. I will check firebug.
    >
    > unico.value is set, yes.
    >
    > In fact i don't receive any error. The window simply does not appear :-


    If there is no error, You should set a breakpoint:

    nuevaurl=url.replace("aaaa",cadena);
    alert(nuevaurl) // breakpoint
    window.open(nuevaurl);

    Then you probably would see the open() statement is not the culprit.

    That is what debugging is about.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Jun 9, 2008
    #6
    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. Ivor O'Connor
    Replies:
    4
    Views:
    904
    Isofarro
    Nov 25, 2003
  2. PeterKellner
    Replies:
    0
    Views:
    609
    PeterKellner
    Jun 1, 2006
  3. Nospam
    Replies:
    4
    Views:
    388
    Nospam
    Jan 27, 2007
  4. Dennis McCarthy

    CheckBoxField works in Firefox but not in IE6

    Dennis McCarthy, Jan 25, 2007, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    113
    Dennis McCarthy
    Jan 25, 2007
  5. Andrzej
    Replies:
    0
    Views:
    77
    Andrzej
    Oct 6, 2003
Loading...

Share This Page