调试旧脚本 [英] debugging an old script

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

问题描述

我有这个预先构建的JS例程,可以创建一个文本动画

特效。该例程包含在免费的HTML编辑器中,

称为AceHTML。问题是它似乎只适用于IE和

IE模拟浏览器(如Opera)。根据其他人的说法,b $ b告诉我,问题是因为这个脚本有一个过时的浏览器

检测方案,而且它用于Netscape的程序不再是

在现代Netscapes / Mozillas等有效。现在,我不是JS专家,我只是

几周前开始做HTML以建立个人页面,所以我

并不期望参与JS编程的内容和

调试,直到很久以后我才会变得更先进。


具体来说,Firefox上的JSconsole错误消息显示任何以document.wds.document.write(...)开头的行

未定义。


如果你想看看这个脚本工作时的样子,那就去

这个网站吧,看看此页面的动画标题(但使用IE或

兼容):

http://ca.geocities.com/bbbl67/mower4sale.html


我需要知道如何使这个东西适用于任何符合W3C标准的浏览器。我理解即使是脚本的IE部分已经过时而且与现代IE无关,但它仍然保持与它的向后兼容性。

Yousuf Khan


我已经从上面提到的页面粘贴了下面的脚本:


---- ------

< script language =" JavaScript">


<! - 开始

//原件:Charles Foster(wc*****@msn.com)


//网站: http://kylo.ml.org/flash

//这个脚本还有更多可用免费在线


// JavaScript来源!! http://javascript.internet.com


var speed = 100;


var cycledelay = 2000;


var maxsize = 28;

var x = 0;


var y = 0;


var themessage,size;


var esize ="< / font>" ;;

函数initArray(){


this.length = initArray.arguments.length;


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


this [i] = initArray.arguments [i];


}


}


var themessage2 = new initArray(


"卖出!",


感谢您的关注


);


if(navigator.appName ==" Netscape")

document.write(''< layer id =" wds">< ; / layer>< br>'');


if(navigator.appVersion.indexOf(&qu) ot; MSIE")!= -1)


document.write(''< span id =" wds">< / span>< br>'' );


函数upwords(){


themessage = themessage2 [y];


if(x< maxsize){


x ++;


setTimeout(" upwords()",speed);


}


else setTimeout(" downwords()",cycledelay);

if(navigator.appName ==" Netscape" ){


size ="< font point-size =''" + x +" pt''>" ;;


document.wds.document.write(size +"< center>" + themes sage +"< / center>" + esize);


document.wds.document.close();


}


if(navigator.appVersion.indexOf(" MSIE"))! = -1){


wds.innerHTML ="< center>" + themessage +"< / center>" ;;


wds.style.fontSize = x +''px'';


}


}

函数downwords(){


if(x> 1){


x--;


setTimeout(" downwords()",speed);


}


否则{


setTimeout(" upwords()",cycledelay);


y ++;


if(y> themessage2.length - 1)y = 0;


}


if(navigator.appName ==" Netscape"){


size ="< font point-size =''" + x +" pt''>" ;;


document.wds.document.write(size +"< center>" + themes sage +"< / center>" + esize);


document.wds .document.close();


}


if(navigator.appVersion.indexOf(" MSIE")!= -1) {


wds.innerHTML ="< center>" + themessage +"< / center>" ;;


wds.style.fontSize = x +''px'';


}


}


setTimeout(" upwords()",speed);


//结束 - >


< / script>

-

人类:请联系我ykhan at rogers dot com

Spambots:只需回复此电子邮件地址; - )

Hi, I have this pre-built JS routine that creates a text animation
special-effect. The routine was included inside a freeware HTML editor,
called AceHTML. The problem is that it seems to work only on IE and
IE-emulating browsers (such as Opera). According to what other people have
told me, the problem is because this script has an outdated browser
detection scheme, and that the procedure it uses for Netscape is no longer
valid in modern Netscapes/Mozillas, etc. Now, I''m no JS expert, I just
started doing HTML a couple of weeks ago to put up a personal page, so I
wasn''t expecting to get involved in the bowels of JS programming and
debugging until much later when I''d become more advanced.

Specifically, the JSconsole error messages on Firefox shows that any lines
that start with "document.wds.document.write(...)" as being undefined.

If you want to see what this script looks like when it''s working, then go to
this site, and look at the animated heading for this page (but use IE or a
compatible):

http://ca.geocities.com/bbbl67/mower4sale.html

I need to know how to make this thing work on any W3C-compliant browser. I
understand that even the IE portion of the script is outdated and irrelevant
to modern IE, but it still maintains backwards compatibility with it.

Yousuf Khan

I''ve pasted the script from the above mentioned page down below:

----------
<script language="JavaScript">

<!-- Begin

// Original: Charles Foster (wc*****@msn.com)

// Web Site: http://kylo.ml.org/flash
// This script and many more are available free online at

// The JavaScript Source!! http://javascript.internet.com

var speed = 100;

var cycledelay = 2000;

var maxsize = 28;
var x = 0;

var y = 0;

var themessage, size;

var esize = "</font>";
function initArray() {

this.length = initArray.arguments.length;

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

this[i] = initArray.arguments[i];

}

}

var themessage2 = new initArray(

"SOLD!",

"Thanks for your interest"

);

if(navigator.appName == "Netscape")

document.write(''<layer id="wds"></layer><br>'');

if (navigator.appVersion.indexOf("MSIE") != -1)

document.write(''<span id="wds"></span><br>'');

function upwords(){

themessage = themessage2[y];

if (x < maxsize) {

x++;

setTimeout("upwords()",speed);

}

else setTimeout("downwords()",cycledelay);
if(navigator.appName == "Netscape") {

size = "<font point-size=''"+x+"pt''>";

document.wds.document.write(size+"<center>"+themes sage+"</center>"+esize);

document.wds.document.close();

}

if (navigator.appVersion.indexOf("MSIE") != -1){

wds.innerHTML = "<center>"+themessage+"</center>";

wds.style.fontSize=x+''px'';

}

}

function downwords(){

if (x > 1) {

x--;

setTimeout("downwords()",speed);

}

else {

setTimeout("upwords()",cycledelay);

y++;

if (y > themessage2.length - 1) y = 0;

}

if(navigator.appName == "Netscape") {

size = "<font point-size=''"+x+"pt''>";

document.wds.document.write(size+"<center>"+themes sage+"</center>"+esize);

document.wds.document.close();

}

if (navigator.appVersion.indexOf("MSIE") != -1){

wds.innerHTML = "<center>"+themessage+"</center>";

wds.style.fontSize=x+''px'';

}

}

setTimeout("upwords()",speed);

// End -->

</script>
--
Humans: contact me at ykhan at rogers dot com
Spambots: just reply to this email address ;-)

推荐答案

On T hu,26 Aug 2004 18:05:59 GMT,Yousuf Khan< bb **** @ ezrs.com>写道:


[snip]
On Thu, 26 Aug 2004 18:05:59 GMT, Yousuf Khan <bb****@ezrs.com> wrote:

[snip]
我需要知道如何使这个东西在任何兼容W3C的浏览器上运行。
据我所知,即使脚本的IE部分已经过时,与现代IE无关,但它仍然保持向后兼容性。
I need to know how to make this thing work on any W3C-compliant browser.
I understand that even the IE portion of the script is outdated and
irrelevant to modern IE, but it still maintains backwards compatibility
with it.




如果我坦率地说,放弃它。创建一个显示相同内容的

动画GIF要简单得多。添加,已售出!感谢您的

兴趣。这样的图片的alt属性也会使您的

页面更容易访问。动画GIF也不会导致页面

维度不断变化。


要制作脚本,另一个例子是高。质量的

JavaScript Source'的集合,可在各种浏览器中使用

要求从头开始重写。考虑到另一种选择,我不认为这是值得的。


[snip]


对不起,

迈克


-

Michael Winter

替换 。无效"与.uk通过电子邮件回复。



If I may be frank, abandon it. It would be much simpler to create an
animated GIF that displayed the same thing. Adding, "Sold! Thanks for your
interest.", to the alt attribute of such an image would also make your
page much more accessible. An animated GIF would also not cause the page
dimensions to constantly change.

To make the script, another example of the "high" quality of The
JavaScript Source''s collection, workable in a wide range of browsers would
require it to be re-written from scratch. Considering the alternative, I
don''t honestly think it''s worth the effort.

[snip]

Sorry,
Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.


迈克尔·温特写道:
如果我坦率地说,放弃它。创建一个显示相同内容的动画GIF要简单得多。添加,已售出!感谢您对此感兴趣。对于此类图片的alt属性,还可以使您的页面更易于访问。动画GIF也不会导致页面尺寸不断变化。


实际上,我有点喜欢这种效果。使它看起来像心跳或

气球。

要制作脚本,另一个例子是高。 JavaScript Source'的集合质量,可在各种浏览器中使用
需要从头开始重新编写。考虑到
替代方案,我不认为这是值得的。
If I may be frank, abandon it. It would be much simpler to create an
animated GIF that displayed the same thing. Adding, "Sold! Thanks for
your interest.", to the alt attribute of such an image would also
make your page much more accessible. An animated GIF would also not
cause the page dimensions to constantly change.
Actually, I kind of liked that effect. Made it look like a heartbeat or a
balloon.
To make the script, another example of the "high" quality of The
JavaScript Source''s collection, workable in a wide range of browsers
would require it to be re-written from scratch. Considering the
alternative, I don''t honestly think it''s worth the effort.




我会接受建议。


Yousuf Khan



I''ll take it with advisement.

Yousuf Khan


2004年8月27日星期五18:53:57 GMT,Yousuf Khan< bb **** @ ezrs.com>写道:
On Fri, 27 Aug 2004 18:53:57 GMT, Yousuf Khan <bb****@ezrs.com> wrote:
迈克尔·温特写道:
如果我坦率地说,放弃它。创建一个显示相同内容的动画GIF要简单得多。添加,已售出!感谢您对此感兴趣。对于此类图片的alt属性,还可以使您的页面更易于访问。动画GIF也不会导致页面尺寸不断变化。
If I may be frank, abandon it. It would be much simpler to create an
animated GIF that displayed the same thing. Adding, "Sold! Thanks for
your interest.", to the alt attribute of such an image would also
make your page much more accessible. An animated GIF would also not
cause the page dimensions to constantly change.



实际上,我有点喜欢这种效果。让它看起来像一个心跳或一个气球。



Actually, I kind of liked that effect. Made it look like a heartbeat or a
balloon.




你错过了这一点。您可以获得相同的效果,只需使用动画

图像,而不是使用字体大小。图像将更容易访问(假设您使用alt属性),并且几乎在每个图形浏览器中都可以保证

[1]。对于

这个剧本或其他任何类似的东西都不能这样说。


[snip]


迈克

[1]几乎因为一些开源图形浏览器没有正确加载

GIF加载,因为GIF压缩专利保证了

算法。


-

Michael Winter

替换.invalid与.uk通过电子邮件回复。



You missed the point. You can get the same effect, just with an animated
image rather than playing around with the font size. An image will be more
accessible (provided that you use the alt attribute), and it''s guaranteed
to work almost in every graphical browser[1]. The same cannot be said for
that script, or any other like it.

[snip]

Mike
[1] "Almost" because some open-source graphical browsers do not implement
GIF loading properly because of the patent held on the GIF compression
algorithm.

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.


这篇关于调试旧脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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