更新时间:2023-01-09 21:39:02
AV写道:Hallo
//////////////////////// //////////
函数myfunc(){
with(this){
prop =" hallo world" ;;
}
}
var foo = new myfunc();
alert(foo.prop)
//////////////////// //////////////
我想用关键字''this''做一个''with''语句,但即使这样简单也是如此片段显然失败了。有什么想法吗?
提前谢谢
有没有特别的理由你不想这样做?
函数myfunc(){
this.prop =" hallo world" ;;
}
var foo = new myfunc();
alert(foo.prop);
AV于2004年1月9日在comp.lang上写道。 javascript :任何想法为什么下面的代码都不起作用?
///////// /////////////////////////
函数myfunc(){
与(this){
prop =" ; hallo world" ;;
}
var foo = new myfunc();
alert(foo.prop)
///// /////////////////////////////
< script>
函数myfunc(){
with(this){
prop =" hallo world";
}
返回窗口
}
var foo = new myfunc();
alert(foo.prop)
/>
< / script>
-
Evertjan。
荷兰。
(请将我的电子邮件地址中的x'变为点数)
Evertjan。写道:AV于2004年1月9日写在comp.lang.javascript :
< script>
function myfunc(){
with(this){
prop =" hallo world";
}
返回窗口
var foo = new myfunc();
alert(foo.prop)
< / script>
你能解释一下吗?这个 - 在这种情况下'返回窗口'究竟做了什么?
Hallo
any idea why the following code doesn''t work?
//////////////////////////////////
function myfunc(){
with(this){
prop="hallo world";
}
}
var foo=new myfunc();
alert(foo.prop)
//////////////////////////////////
I want to make a ''with'' statement work with the keyword ''this'' but even that
simple snippet apparently fails. Any idea?
thank you in advance
AV wrote:Hallo
any idea why the following code doesn''t work?
//////////////////////////////////
function myfunc(){
with(this){
prop="hallo world";
}
}
var foo=new myfunc();
alert(foo.prop)
//////////////////////////////////
I want to make a ''with'' statement work with the keyword ''this'' but
even that simple snippet apparently fails. Any idea?
thank you in advance
Is there a specific reason you don''t want to do it this way??
function myfunc() {
this.prop = "hallo world";
}
var foo = new myfunc();
alert(foo.prop);
AV wrote on 09 jan 2004 in comp.lang.javascript:any idea why the following code doesn''t work?
//////////////////////////////////
function myfunc(){
with(this){
prop="hallo world";
}
}
var foo=new myfunc();
alert(foo.prop)
//////////////////////////////////
<script>
function myfunc(){
with(this){
prop="hallo world";
}
return window
}
var foo=new myfunc();
alert(foo.prop)
</script>
--
Evertjan.
The Netherlands.
(Please change the x''es to dots in my emailaddress)
Evertjan. wrote:AV wrote on 09 jan 2004 in comp.lang.javascript:
<script>
function myfunc(){
with(this){
prop="hallo world";
}
return window
}
var foo=new myfunc();
alert(foo.prop)
</script>
Could you explain this - what exactly does ''return window'' do in this case?