为什么脚本崩溃IE? [英] why does the script crash IE?

查看:88
本文介绍了为什么脚本崩溃IE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我只有IE进行测试。


好​​的。我有一个脚本应该显示,而不是评估

无限积分的东西。当我运行脚本时它就会崩溃

IE。我试图搞清楚所有明显的错误......嗯......脚本是

at: http://ali.freezope.org/idf 测试以及它应该显示的内容是

at: http://ali.freezope.org/idf 结果

解决方案

greenflame写道:

首先,我只有IE进行测试。

好的。我有一个脚本应该显示,而不是评估,
无限的积分。当我运行脚本时,它只是简单地用IE浏览器。我试图把所有明显的错误都拿出来...嗯......剧本是: http://ali.freezope.org/idf 测试以及它应该显示的内容是: http://ali.freezope.org/idf 结果




帖子网址如此:


< URL: http:// ali .freezope.org / idf 结果>


特别是如果你的URL中有空格。


你应该警告用户如果JavaScript是导致''崩溃'的原因,那么他们会在点击链接之前明确地转换JavaScript。

浏览器没有崩溃,你将它发送到你的

indefiniteintegral()函数中的永无止境的循环。

函数indefiniteintegral (输入,主线,差异){

var dummy;

var output = copy2darr(输入);

dummy = output.unshift(new数组(输出[0] .length));

dummy = output.push(新数组(输出[0] .length));

为什么要指定一些数字给变量''dummy'',然后覆盖它,然后

再次在下面这样做?


for(var i = 0; i< output.length ; i ++){

----------------- ^^^^^^^^^^^^^


这里每个循环都会计算output.length的值。这很慢

,在这种情况下,会创建一个无限循环。使用变量存储

output.length的值(它也会略微加快你的循环):


for(var i = 0,len如果(i == 0){

dummy = output [i] .unshift("< font) face = symbol>ó< / font>");

dummy = output [i] .push("");

不要使用这样的过时的HTML - 使用span元素,最好使用DOM

而不是document.write。并创建一个类,所以你没有

多种样式声明:


dummy = output [i] .unshift(''< span style =" font-family:symbol">''

+''ó< / span>'');


或者,如果使用CSS和类,头部有一个样式声明:


< style type =" text / css">

.sym {font-family :符号; }

然后是



dummy = output [i] .unshift(''< span class =" sym"> + ''ó< / span>'');

}否则if(i == mainline){

dummy = output [i] .unshift("< font face = symbol>ô< / font>");

dummy = output [i] .push(差异);

}否则if(i == output) .length-1){

dummy = output.unshift("< font face = cymbol>õ< / font>");

---- ---------- ^^^^^^^^^


这里你把东西放到输出中并使它更长,而你的
$ b循环的$ b试图赶上 - 它永远不会。在折旧的字体标记中你也有一个错误

- 我想你想要''符号'',而不是''cymbol''。

dummy = output [i] .unshift("< font face = cymbol>õ< / font>");

dummy = output [i] .push("");

} else {

dummy = output.unshift("< font face = symbol>ô< / font>");

----- --------- ^^^^^^^^^


和这里一样。


dummy =输出[i] .push("");

}

}

返回输出;

}

修复以上内容主要是修复你的输出,但不完全适合我。

其他评论:


*在你的copy2darr中( )功能,行:


var output = new Array(input.length);


可替换为:


var output = [];


*文件开头的折旧''font''元素应为

替换为跨度, pre或code元素:


< font face =" courier new"> ...< / font>成为:


< pre> ...< / pre>


*所有这些行:


if(input ==" del"){ output ="< font face = symbol>Ñ< / font>"}

可以通过在
$ b开头创建以下变量来替换$ b功能:


var fOn =''< font face =" symbol">''

var fOf =''< /字体>''


然后使用:


if(input ==" del"){output = fOn +''Ñ' '+ fOf}

你真的应该使用带有CSS的span元素,但我不知道

适当的font-family来替换符号 - 试试:


comp.infosystems。 www.authoring.stylesheets

-

Rob


RobG写道:

greenflame写道:

[...]
其他评论:




修改你的convert()函数,如下所示:


函数convert(inVal){

var sOn =''< font face =" symbol">''

var sOf =''< / font>''


if(inVal == undefined){return "&安培; NBSP;" }

if(inVal ==" hyf"){return" - " }

if(inVal ==" vA"){return"< b> A< / b>" }

...

...

...

if(inVal =="] b"){return sOn +''''+ sOf}

}


你的顺序if''会测试每一个''如果' '每次。

修改上面的脚本将在匹配结束后立即返回调用函数




当''输出''没有以任何方式修改'b $ b'时,将''输入''复制到''输出''也毫无意义 - 它只是在测试中使用。

-

Rob


RobG< rg *** @ iinet.net.auau>写道:

帖子URL因此:
< URL: http://ali.freezope.org/idf 结果>


最好是有效的URL(不含空格):

< URL:http://ali.freezope.org/idf%20result>

< font face = symbol>ô< / font>




虽然这是原始海报正在尝试的正确形式

要做,它仍然不是正确的方法。


实体ô代表带代码点的Unicode字符

244 ,即? (也称为& ocirc;,具有回音重音的o)。

然后尝试以字体符号呈现。问题是

该字体不包含o-circumflex的字形。


早些时候,当Unicode不那么广泛并且一切正常时

使用8位编码,Symbol字体的字形被映射到

8位值,因此以该字体呈现字节244将给出

字体文件的第244个条目。那些日子结束了。现代

字体识别程序,包含的浏览器,不会在符号字体中呈现ô

,但会回落到指定的下一个字体上

字体标记或浏览器的默认字体。


没有Unicode代码点表示

整数符号的前三分之一 ;,因为Unicode仅代表整个符号。

整数符号可以写成&#8747或& #int;。我推荐

类似于:


< p style =" line-height:300%">

< span style =" font-size:300%; vertical-align:middle;">∫< / span> x dx

< / p>


确切的垂直对齐有点难以跨越

浏览器。

(在这里阅读更多关于HTML中的符号:

< URL:http://www.w3.org/TR/WD-entities-961125>)


页面的编码未指定页面本身或

服务器,所以浏览器必须猜测。我可以看到我的浏览器

猜猜windows-1252。您应该从服务器指定一个编码,最好是
,但如果不是,则作为页面的一个元素:

< meta http-equiv =" Content-type" ;含量=" text / html的; charset = iso-8859-15">


后续设置为comp.infosystems。 www.authoring.html ,因为这个
是关于HTML的,而不是javascript。


/ L

-

Lasse Reichstein Nielsen - lr*@hotpop.com

DHTML死亡颜色:< URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>

''没有判断的信仰只会降低精神神圣。''


First of all I only have IE for testing.

Ok. I have a script that is supposed to show, not evaluate, the
indefinite integral of something. When I run the script it just craches
IE. I have tried to get all the obvious bugs out... Um... The script is
at: http://ali.freezope.org/idf test and what it is supposed to show is
at: http://ali.freezope.org/idf result

解决方案

greenflame wrote:

First of all I only have IE for testing.

Ok. I have a script that is supposed to show, not evaluate, the
indefinite integral of something. When I run the script it just craches
IE. I have tried to get all the obvious bugs out... Um... The script is
at: http://ali.freezope.org/idf test and what it is supposed to show is
at: http://ali.freezope.org/idf result



Post URL''s thusly:

<URL:http://ali.freezope.org/idf result>

especially if you have spaces in the URL.

You should probably warn users explicitly to turn of JavaScript before
they click on the link if JavaScript is the cause of the ''crash''. The
browser doesn''t crash, you send it into a never-ending loop in your
indefiniteintegral() function.
function indefiniteintegral(input,mainline,differential) {
var dummy;
var output = copy2darr(input);
dummy = output.unshift(new Array(output[0].length));
dummy = output.push(new Array(output[0].length));
Why assign some number to the variable ''dummy'', then overwrite it, then
do so again below?

for (var i=0;i<output.length;i++) {
-----------------^^^^^^^^^^^^^

Here the value of output.length is evaluated every loop. This is slow
and, in this case, creates an infinite loop. Use a variable to store
the value of output.length (it will also slightly speed up your loop):

for (var i=0, len=output.length; i<len; i++) {
if (i == 0) {
dummy = output[i].unshift("<font face=symbol>ó</font>");
dummy = output[i].push(" ");
Don''t use such outdated HTML - use span elements, preferably using DOM
rather than document.write. And create a class so you don''t have
numerous style declarations:

dummy = output[i].unshift(''<span style="font-family:symbol">''
+ ''ó</span>'');

or, if using CSS and classes, have a style declaration in the head:

<style type="text/css">
.sym { font-family: symbol; }

then:

dummy = output[i].unshift(''<span class="sym"> + ''ó</span>'');
} else if (i == mainline) {
dummy = output[i].unshift("<font face=symbol>ô</font>");
dummy = output[i].push(differential);
} else if (i == output.length-1) {
dummy = output.unshift("<font face=cymbol>õ</font>");
--------------^^^^^^^^^

Here you are putting stuff into output and making it longer while your
for loop is trying to catch up - it never will . You also have a fault
in the depreciated font tag - I think you want ''symbol'', not ''cymbol''.
dummy = output[i].unshift("<font face=cymbol>õ</font>");
dummy = output[i].push(" ");
} else {
dummy = output.unshift("<font face=symbol>ô</font>");
--------------^^^^^^^^^

And the same here.

dummy = output[i].push(" ");
}
}
return output;
}
Fixing the above mostly fixes your output, but not entirely for me.
Other comments:

* In your copy2darr() function, the line:

var output = new Array(input.length);

can be replaced with:

var output = [];

* The depreciated ''font'' element at the start of your file should be
replaced with either a span, pre or code element:

<font face="courier new"> ... </font> becomes:

<pre> ... </pre>

* All of those lines with:

if (input == "del") {output = "<font face=symbol>Ñ</font>"}

can be replaced by creating the following variables at the start of the
function:

var fOn = ''<font face="symbol">''
var fOf = ''</font>''

then use:

if (input == "del") {output = fOn + ''Ñ'' + fOf }
You really should be using span elements with CSS, but I don''t know the
appropriate font-family to replace symbol - try in:

comp.infosystems.www.authoring.stylesheets
--
Rob


RobG wrote:

greenflame wrote:
[...]
Other comments:



Modify your convert() function as follows:

function convert( inVal ) {
var sOn = ''<font face="symbol">''
var sOf = ''</font>''

if (inVal == undefined){ return "&nbsp;" }
if (inVal == "hyf") {return "—" }
if (inVal == "vA" ) {return "<b>A</b>" }
...
...
...
if (inVal == "]b") {return sOn + ''û'' + sOf}
}

Your sequential if''s will test every single ''if'' every single time.
Modifying the script as above will return to the calling function as
soon as the match is found.

It is also pointless to copy ''input'' to ''output'' when ''output'' is not
modified in any way - it''s just used in the test.
--
Rob


RobG <rg***@iinet.net.auau> writes:

Post URL''s thusly: <URL:http://ali.freezope.org/idf result>
Preferably as a valid URL (without spaces):
<URL:http://ali.freezope.org/idf%20result>
<font face=symbol>ô</font>



While this is the correct form of what the original poster is trying
to do, it is still not the correct way to do it.

The entity ô represents the Unicode character with code point
244, i.e., ? (also known as &ocirc;, an o with a circumflex accent).
It is then attempted rendered in the font "Symbol". The problem is
that that font does not contain a glyph for o-circumflex.

Earlier, when Unicode was not as widespread and everything worked
using 8-bit encodings, the glyphs of the Symbol font was mapped to
8-bit values, so rendering the byte 244 in that font would give
the 244th entry of the font file. Those days are over. Modern
font-aware programs, browsers included, will not render ô
in the symbol font, but will fall back on the next font specified
in a font tag, or the browser''s default font.

There is no Unicode codepoint representing "the top third of an
integral sign", because Unicode represents entire symbols only.
The integral sign can be written as &#8747 or &#int;. I recommend
something like:

<p style="line-height:300%">
<span style="font-size:300%;vertical-align:middle;">∫</span>x dx
</p>

The exact vertical alignment is a little hard to get right across
browsers.
(read more about symbols in HTML here:
<URL:http://www.w3.org/TR/WD-entities-961125>)

The encoding of the page is not specified by either the page itself or
the server, so the browser must guess. I can see that my browser
guesses "windows-1252". You should specifiy an encoding, preferably
from the server, but if not, as an element of the page:
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-15">

Follow-up set to comp.infosystems.www.authoring.html, since this
is about HTML, not javascript.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
''Faith without judgement merely degrades the spirit divine.''


这篇关于为什么脚本崩溃IE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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