IE6嵌套问题? [英] IE6 Nesting Problem?

查看:60
本文介绍了IE6嵌套问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我试图从

地址行获取一些javascript在IE6中工作。它适用于Firefox,我相信,IE7。


看来,有了一些嵌套结构,代码确实没有执行
。取一两个水平,它的工作原理。下面的代码是

废话,但说明了问题。


这个有效:


javascript :for(a = 1; a< = 10; a ++){for(b = 1; b< = 10; b ++){if(q <1000)

{for( c = 1; c <= 10; c ++){for(d = 1; d <= 10; d ++){if(a 0){if(a<

2000){x = 10; Q ++; for(a = 1; a< = 10; a ++)

{for(b = 1; b< = 10; b ++){if(q< 1000){ for(c = 1; c <= 10; c ++)

{for(d = 1; d< = 10; d ++){if(a 0){x = 10; Q ++; } $}

alert(q); void(0);


但这不是:


javascript :for(a = 1 ; a< = 10; a ++){for(b = 1; b< = 10; b ++){if(q <1000)

{for(c = 1; c< = 10; c ++ ){for(d = 1; d< = 10; d ++){if(a 0){if(a<

2000){x = 10; Q ++; for(a = 1; a< = 10; a ++)

{for(b = 1; b< = 10; b ++){if(q< 1000){ for(c = 1; c <= 10; c ++)

{for(d = 1; d< = 10; d ++){if(a 0){if(a< 2000){ X = 10; q +

+;警报(q); void(0);


我已经尝试过声明变量,等等等等。仍然休息。

这是一个内存问题吗?我错过了代码中明显的东西吗?

感谢您的帮助!


这里有一个漂亮的版本:


javascript

for(a = 1; a< = 10; a ++){

for(b = 1; b< = 10; b ++){

if(q< 1000){

for(c = 1; c< = 10; c ++){

代表(d = 1; d <= 10; d ++){

if(a 0){

if(a< 2000){

x = 10;

q ++;

}

}

}

}

}

}

}

for(a = 1; a< = 10; a ++) {

for(b = 1; b< = 10; b ++){

if(q <1000){

for(c = 1; c< = 10; c ++){

for(d = 1; d< = 10; d ++){

if(a 0){

if(a< 2000){

x = 10;

q ++;

}

}

}

}

}

}

}

alert(q);

void(0);

解决方案

3月14日,12:57 p m,bweaveruse ... @ gmail.com写道:


嗨。我试图从

地址行获取一些javascript在IE6中工作。它适用于Firefox,我相信,IE7。


看来,有了一些嵌套结构,代码确实没有执行
。取一两个水平,它的工作原理。下面的代码是

废话,但说明了问题。


这个有效:



它没有。


>

javascript :for(a = 1; a< = 10; a ++){for(b = 1; b< = 10; b ++){if(q< 1000)



错误:q未定义。


如果您希望其他人考虑您的问题,请发布易于阅读的代码。另外:


- 突出工作和不工作之间的差异

代码

- 建议结果表明''它有效''

- 报告你收到的任何错误信息

-

Rob


3月13日晚上11:51,RobG < r ... @ iinet.net.auwrote:


3月14日下午12:57,bweaveruse ... @ gmail.com写道:


嗨。我试图从

地址行获取一些javascript在IE6中工作。它适用于Firefox,我相信,IE7。


看来有了一些嵌套结构,代码确实没有执行
。取一两个水平,它的工作原理。下面的代码是

废话,但说明了问题。


这个有效:



它没有。
< blockquote class =post_quotes>
javascript :for(a = 1; a< = 10; a ++){for(b = 1; b< = 10; b ++){if( q< 1000)



错误:q未定义。


如果您希望其他人考虑您的问题,请发布代码这很容易就读了b $ b。另外:


- 突出工作和不工作之间的差异

代码

- 建议结果表明''它有效''

- 报告你收到的任何错误信息


-

Rob



你好Rob。


我将工作和损坏的代码发布到
$ b $的地址栏中b浏览器,但是为了便于阅读,我还发布了一个破旧的

代码。代码*的第一位*在浏览器地址字段中的IE6(以及

firefox等)中工作。我知道q没有定义

但是b c和d都不是。正如我在帖子中提到的那样,我已经尝试了b / b
声明变量,结果类似。


两个snippits的差异是一个额外的(a<

2000)测试第二组嵌套for循环。删除该测试

产生工作警报(q),而将其保留在中。


我没有收到任何错误消息,除非它们被隐藏在某些控制台中

某处。


无论如何,除非我有一些明显的语法错误,关键是

有一些嵌套结构(循环,测试等)似乎

使IE6浏览器地址栏中的javascript无法正常工作。由于我是

而不是IE6的javascript高手,我以为它可能会响铃,而这里有人带来了这个。


谢谢。


3月14日上午10:00,bweaveruse ... @ gmail.com写道:


我将工作和损坏的代码复制到浏览器的地址栏中,但是我还发布了一个打破了

代码的漂亮版本以便于阅读。代码*的第一位*在IE6中工作



不,它没有 - 至少在编程意义上的工作这个词。

对工作的哲学解释作为具有未实现的工作潜力b $ b和猜想类似的东西在这里是无关紧要的我猜...-)

Rob已经指出了问题:因为你没有实例化q

变量,通过达到语句if(q < 1000)你得到

"未定义标识符"运行时错误。在循环之前添加q = 0之后

程序_works_所以它执行所有循环并警告1000.

这样你发布的特定代码没有UA依赖的问题

但是它有正确的编码错误。


在一次重大的运行中,一个非常大的书签在IE上不起作用吗?

的答案是肯定的,你可能会达到IE规定的URL长度限制(6美元/ b $ b和7)。此限制为2,048个字符减去实际路径中的字符数

。 javascript :伪协议也受此

限制的影响。因为超出的部分只是被截断,所以如果用于书签,本身代码本身的代码可能会被破坏。这个

是为什么制作特别复杂的书签或很长时间

GET请求密切关注字符串长度。


希望它有帮助。


PS另请参见 http://support.microsoft.com/kb/208427


Hi. I am trying to get some javascript to work in IE6, from the
address line. It works in Firefox and, I believe, IE7.

It appears that with some number of nested structures, the code does
not execute. Take a level or two out and it works. The code below is
nonsense, but illustrates the problem.

This works:

javascript: for( a=1;a<=10;a++ ) { for( b=1;b<=10;b++ ) { if( q<1000 )
{ for( c=1;c<=10;c++ ) { for( d=1;d<=10;d++ ) { if( a 0 ) { if( a <
2000 ) { x=10; q++; } } } } } } } for( a=1;a<=10;a++ )
{ for( b=1;b<=10;b++ ) { if( q<1000 ) { for( c=1;c<=10;c++ )
{ for( d=1;d<=10;d++ ) { if( a 0 ) { x=10; q++; } } } } } }
alert( q ); void( 0 );

But this doesn''t:

javascript: for( a=1;a<=10;a++ ) { for( b=1;b<=10;b++ ) { if( q<1000 )
{ for( c=1;c<=10;c++ ) { for( d=1;d<=10;d++ ) { if( a 0 ) { if( a <
2000 ) { x=10; q++; } } } } } } } for( a=1;a<=10;a++ )
{ for( b=1;b<=10;b++ ) { if( q<1000 ) { for( c=1;c<=10;c++ )
{ for( d=1;d<=10;d++ ) { if( a 0 ) { if( a < 2000 ) { x=10; q+
+; } } } } } } } alert( q ); void( 0 );

I''ve tried declaring the variables, blah blah blah. Still breaks. Is
this a memory issue? Am I missing something obvious in the code?
Thanks for any help!

Here''s a prettied version:

javascript:
for( a=1;a<=10;a++ ) {
for( b=1;b<=10;b++ ) {
if( q<1000 ) {
for( c=1;c<=10;c++ ) {
for( d=1;d<=10;d++ ) {
if( a 0 ) {
if( a < 2000 ) {
x=10;
q++;
}
}
}
}
}
}
}
for( a=1;a<=10;a++ ) {
for( b=1;b<=10;b++ ) {
if( q<1000 ) {
for( c=1;c<=10;c++ ) {
for( d=1;d<=10;d++ ) {
if( a 0 ) {
if( a < 2000 ) {
x=10;
q++;
}
}
}
}
}
}
}
alert( q );
void( 0 );

解决方案

On Mar 14, 12:57 pm, bweaveruse...@gmail.com wrote:

Hi. I am trying to get some javascript to work in IE6, from the
address line. It works in Firefox and, I believe, IE7.

It appears that with some number of nested structures, the code does
not execute. Take a level or two out and it works. The code below is
nonsense, but illustrates the problem.

This works:

It doesn''t.

>
javascript: for( a=1;a<=10;a++ ) { for( b=1;b<=10;b++ ) { if( q<1000 )

Error: q is not defined.

If you want others to consider your question, post code that is easily
read. Also:

- highlight the differences between the ''working'' and ''not working''
code
- advise what result indicates ''it works''
- report any error messages you get
--
Rob


On Mar 13, 11:51 pm, "RobG" <r...@iinet.net.auwrote:

On Mar 14, 12:57 pm, bweaveruse...@gmail.com wrote:

Hi. I am trying to get some javascript to work in IE6, from the
address line. It works in Firefox and, I believe, IE7.

It appears that with some number of nested structures, the code does
not execute. Take a level or two out and it works. The code below is
nonsense, but illustrates the problem.

This works:


It doesn''t.

javascript: for( a=1;a<=10;a++ ) { for( b=1;b<=10;b++ ) { if( q<1000 )


Error: q is not defined.

If you want others to consider your question, post code that is easily
read. Also:

- highlight the differences between the ''working'' and ''not working''
code
- advise what result indicates ''it works''
- report any error messages you get

--
Rob

Hi Rob.

I posted the working and broken code as copied into the address bar of
the browser, however I also posted a prettied version of the broken
code for readability. The first bit of code *does* work in IE6 (and
firefox etc) from the browser address field. I realize q isn''t defined
but neither are a b c and d. As I also mentioned in my post, I have
tried declaring the variables, with similar results.

The difference in the two snippits is a single additional if( a <
2000 ) test in the second set of nested for loops. Removing that test
yields the working alert( q ) while leaving it in does not.

I get no error messages, unless they are buried in some console
somewhere.

Regardless, unless I have some obvious syntactical error, the point is
that some number of nesting structures (loops, tests, etc.) appears to
make javascript from the IE6 browser address bar not work. Since I am
not an IE6 javascript whiz, I thought it might ring a bell with
someone here.

Thanks.


On Mar 14, 10:00 am, bweaveruse...@gmail.com wrote:

I posted the working and broken code as copied into the address bar of
the browser, however I also posted a prettied version of the broken
code for readability. The first bit of code *does* work in IE6

No, it doesn''t - at least in the programming sense of the word "work".
Phylosophical interpretations of "work" as "having a unrealized
potention to work" and similar are irrelevant here I guess ;-)
Rob pointed out the problem already: because you didn''t instantiate q
variable, by reaching the statement if (q < 1000) you are getting
"Undefined identifier" run-time error. After adding q = 0 before loops
the program _works_ so it executes all loops and alerts 1000.
This way the particular code your posted has no UA-dependant problems
but it has the pointed coding error to correct.

On a big run as "can a very big bookmarklet do not work on IE?" the
answer is yes, you may hit the URL length limit imposed by IE (both 6
and 7). This limit is 2,048 characters minus the number of characters
in the actual path. javascript: pseudo-protocol is affected by this
limit as well. Because the exceeding part is simply being truncated, a
proper by itself code may become broken if used for bookmarklet. This
is why while making especially complicated bookmarklet or very long
GET requests watch closely the string length.

Hope it helps.

P.S. See also http://support.microsoft.com/kb/208427


这篇关于IE6嵌套问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆