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

D

dlf

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!
 
B

Bart Friederichs

dlf said:
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
 
E

Evertjan.

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!
 
Á

Álvaro G. Vicario

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.
 
D

dlf

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


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!

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
 
E

Evertjan.

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

[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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top