Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Window.open. Works in ie6. Does not work in firefox

Reply
Thread Tools

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

 
 
dlf
Guest
Posts: n/a
 
      06-09-2008

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!

 
Reply With Quote
 
 
 
 
Bart Friederichs
Guest
Posts: n/a
 
      06-09-2008
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
 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      06-09-2008
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)
 
Reply With Quote
 
Álvaro G. Vicario
Guest
Posts: n/a
 
      06-09-2008
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
--
 
Reply With Quote
 
dlf
Guest
Posts: n/a
 
      06-09-2008
On 9 jun, 17:46, "Evertjan." <exjxw.hannivo...@interxnl.net> 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
 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      06-09-2008
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)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ajax in sync mode works with IE, does not work with Firefox zalek Javascript 33 10-19-2008 12:52 PM
Form does not work in firefox, but works in IE sipuebla@gmail.com Javascript 4 10-17-2005 01:32 PM
<img onload= does not work in FireFox 1.0 but works in IE Luke Venediger Javascript 3 03-08-2005 08:13 PM
Webservice works once and then DOES NOT seem to work even though program does not crash Phi! ASP .Net Web Services 1 04-23-2004 08:42 AM
After rebooting my PC works, works, works! Antivirus problem? Adriano Computer Information 1 12-15-2003 05:30 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57