且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

奇怪的IE漏洞

更新时间:2023-09-11 21:23:28


lo *** **@fastmail.fm 写道:
div.class =" tabContentPaneDiv&quot ;;




没有错误。要更改元素的类,正确的语法

是:


element.className =" classname";


将其更改为上述内容将导致您的警报显示。




web.dev写道: lo*****@fastmail.fm 写道:
div.class =" tabContentPaneDiv";



没有错误。要更改元素的类,正确的语法是:

element.className =" classname&quot ;;

将其更改为上面将导致您的警告显示。




好​​的 - 我原来想要的是什么,但我还有错误的属性名称,但是仍有据我所知,这是一个错误。如果您更改上面的

行,那么函数显示为:


函数notCalled(){

var div = {class :0};

div.class =" tabContentPaneDiv&quot ;;

}


警报未显示。它在Firefox中。这不应该发生我想b / b
想想。


关键是函数永远不会被调用,所以唯一的时间是

javascript翻译应该在检查语法时查看它。

此时,解释器不应该为div

变量是dom节点还是打扰其他一些对象。但是即使它没有被调用,因此分配给属性名称''class'会导致

程序永远无法运行。




loft ... @ fastmail.fm写道:
web.dev写道:
lo*****@fastmail.fm 写道:
div.class =&quot ; tabContentPaneDiv";



没有错误。要更改元素的类,正确的语法是:

element.className =" classname&quot ;;

将其更改为上面将导致您的警告显示。



好的 - 我原来试图做的事情的属性名称错了,但就我所见,还有一个错误。如果您更改其上方的
行,则函数显示为:

函数notCalled(){
var div = {class:0};
div.class = tabContentPaneDiv;
}

警报没有显示出来。它在Firefox中。这不应该发生我想。

关键是函数永远不会调用,所以
javascript解释器应该只查看它的时候是检查语法。
此时,解释器不应该为div
变量是dom节点还是其他类型的对象而烦恼。但即使没有调用它,分配给属性名称''class'会导致
程序永远无法运行。




我刚刚发现''class''是javascript中的保留字,

可以解释这个,但如果是,则解释器应该给出语法

错误,而不仅仅是停止。这也无法解释为什么它在

firefox中运行正常。


I found what looks like a definite bug in IE. If you load the page
below in Firefox, the alert comes up as you would expect. If you run it
in IE6 (with sp2), the alert doesn''t come up. commenting out the line
that starts ''div.class'' makes it work. This is very weird, as far as I
can see - the code is not run, and it''s not generating a syntax error,
but it''s still preventing the rest of the program from running. All I
can guess is that the javascript parser has crashed on that line for
some reason without returning an error. It is possible to work round
this using setAttribute, but it''s annoying nonetheless.

<html>
<head><title>bug test</title>
<script type="text/javascript">
function notCalled() {
var div=document.createElement("div");
div.class="tabContentPaneDiv";
}

alert("here");
</script>
</head>
<body>
<h1>IE Bug Test</h1>
</body>
</html>


lo*****@fastmail.fm wrote:
div.class="tabContentPaneDiv";



There is no bug. To alter a class for an element, the correct syntax
is:

element.className = "classname";

Changing it to the above will cause your alert to show up.



web.dev wrote:
lo*****@fastmail.fm wrote:
div.class="tabContentPaneDiv";



There is no bug. To alter a class for an element, the correct syntax
is:

element.className = "classname";

Changing it to the above will cause your alert to show up.



OK - I had the wrong attribute name for what I was originally trying to
do, but there is still a bug as far as I can see. If you change the
line above it so the function reads:

function notCalled() {
var div={class:0};
div.class="tabContentPaneDiv";
}

The alert doesn''t show up. It does in Firefox. This shouldn''t happen I
think.

The point is the function is never called, so the only time the
javascript interpreter should look at it is when checking for syntax.
At this point, the interpreter shouldn''t be bothered whether the div
variable is a dom node or some other kind of object. But even though
it''s not called, assigning to the property name ''class'' causes the
program never to be run.



loft...@fastmail.fm wrote:
web.dev wrote:
lo*****@fastmail.fm wrote:
div.class="tabContentPaneDiv";



There is no bug. To alter a class for an element, the correct syntax
is:

element.className = "classname";

Changing it to the above will cause your alert to show up.



OK - I had the wrong attribute name for what I was originally trying to
do, but there is still a bug as far as I can see. If you change the
line above it so the function reads:

function notCalled() {
var div={class:0};
div.class="tabContentPaneDiv";
}

The alert doesn''t show up. It does in Firefox. This shouldn''t happen I
think.

The point is the function is never called, so the only time the
javascript interpreter should look at it is when checking for syntax.
At this point, the interpreter shouldn''t be bothered whether the div
variable is a dom node or some other kind of object. But even though
it''s not called, assigning to the property name ''class'' causes the
program never to be run.



I just found out that ''class'' is a reserved word in javascript, which
may explain this, though if it is, the interpreter should give a syntax
error, not just stop. This also doesn''t explain why it runs OK in
firefox.