Thank you very much in advance. I work from a tutorial, and they use one function to call another, which opens a window:
function rtest(){
content='dans window';
oneWindow=open("","Window 1","width=450,height=290");
newWindow(oneWindow);
}
function newWindow(x){
x.document.close();
x.document.open();
x.document.write(content);
x.document.close();
x.moveTo(20,20);
x.focus();
}
So, everything works fine, but my question is this: how can the newWindow () function access the contents of the “content” in the rtest () function? And why, if I preface the variable "content" with "var", like this:
function rtest(){
**var content='dans window';**
oneWindow=open("","OneWindow","width=450,height=290");
newWindow(oneWindow);
}
... an error occurs (and the contents of the new window remain empty)?
Can someone explain to me what the difference is between using var and not using var?
Thank!
Daniel
source
share