JavaScript variable interpolation

Hi everybody,

Firstly, this would be the first time I'm using JavaScript. My background is mainly Perl. Nevertheless, here's my problem.

So I've created a function

function linkout(url){
   setTimeout("window.open(url)",5000) //in milliseconds
}

However because the variable "url" is within the double quotes, it doesn't interpolate the "url" variable being passed to the function (or so I think since it doesn't work. How do I check JavaScript errors anyway?).

If I remove the double quotes, the window.open works but without the setTimeout delay of 5 seconds.

Can anyone help shed some light?

Thanks in advance!

Dave

---------- Post updated at 15:10 ---------- Previous update was at 14:27 ----------

So I saw some code that was in this syntax '"+var+"' and I changed my variable to that and it works.

function linkout(url){
   setTimeout("window.open('"+url+"','newwindow')",5000);
}

Don't know why though.

Dave